Background

This file is designed to use CDC data to assess coronavirus disease burden by state, including creating and analyzing state-level clusters.

Through March 7, 2021, The COVID Tracking Project collected and integrated data on tests, cases, hospitalizations, deaths, and the like by state and date. The latest code for using this data is available in Coronavirus_Statistics_CTP_v004.Rmd.

The COVID Tracking Project suggest that US federal data sources are now sufficiently robust to be used for analyses that previously relied on COVID Tracking Project. This code is an attempt to update modules in Coronavirus_Statistics_CTP_v004.Rmd to leverage US federal data.

The code in this module builds on code available in _v002 to include vaccines data:

Broadly, the CDC data analyzed by this module includes:

Functions and Mapping Files

The tidyverse package is loaded and functions are sourced:

# The tidyverse functions are routinely used without package::function format
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.1.1     v dplyr   1.0.6
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
# Functions are available in source file
source("./Generic_Added_Utility_Functions_202105_v001.R")
source("./Coronavirus_CDC_Daily_Functions_v001.R")

A series of mapping files are also available to allow for parameterized processing. Mappings include:

These default parameters are maintained in a separate .R file and can be sourced:

source("./Coronavirus_CDC_Daily_Default_Mappings_v002.R")

Example for Comparison to Previous

The function is tested on existing, previously downloaded data:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_210801.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_210801.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_210801.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210708")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210708")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210728_vaxonly")$dfRaw$vax
                    )

cdc_daily_210801_test <- readRunCDCDaily(thruLabel="Jul 31, 2021", 
                                         downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                         readFrom=readList,
                                         compareFile=compareList, 
                                         writeLog=NULL, 
                                         useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                         weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                            "vxcpm7", "vxcgte65pct"
                                                            ),
                                         skipAssessmentPlots=FALSE, 
                                         brewPalette="Paired"
                                         )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_210801.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 25
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths      143      152        9 0.06101695
## 2   2020-02-03 tot_deaths      143      152        9 0.06101695
## 3   2020-02-04 tot_deaths      143      152        9 0.06101695
## 4   2020-02-05 tot_deaths      143      152        9 0.06101695
## 5   2020-02-06 tot_deaths      143      152        9 0.06101695
## 6   2020-02-07 tot_deaths      143      152        9 0.06101695
## 7   2020-02-08 tot_deaths      144      153        9 0.06060606
## 8   2020-02-09 tot_deaths      144      153        9 0.06060606
## 9   2020-02-10 tot_deaths      144      153        9 0.06060606
## 10  2020-02-11 tot_deaths      144      153        9 0.06060606
## 11  2020-02-12 tot_deaths      144      153        9 0.06060606
## 12  2020-02-13 tot_deaths      144      153        9 0.06060606
## 13  2020-02-14 tot_deaths      144      153        9 0.06060606
## 14  2020-02-15 tot_deaths      144      153        9 0.06060606
## 15  2020-02-16 tot_deaths      144      153        9 0.06060606
## 16  2020-02-17 tot_deaths      144      153        9 0.06060606
## 17  2020-02-18 tot_deaths      144      153        9 0.06060606
## 18  2020-02-19 tot_deaths      145      154        9 0.06020067
## 19  2020-02-20 tot_deaths      145      154        9 0.06020067
## 20  2020-02-21 tot_deaths      145      154        9 0.06020067
## 21  2020-02-22 tot_deaths      145      154        9 0.06020067
## 22  2020-02-23 tot_deaths      145      154        9 0.06020067
## 23  2020-02-24 tot_deaths      145      154        9 0.06020067
## 24  2020-02-25 tot_deaths      145      154        9 0.06020067
## 25  2020-02-26 tot_deaths      145      154        9 0.06020067
## 26  2020-02-27 tot_deaths      146      155        9 0.05980066
## 27  2020-02-28 tot_deaths      146      155        9 0.05980066
## 28  2020-02-29 tot_deaths      147      156        9 0.05940594
## 29  2020-03-01 tot_deaths      147      156        9 0.05940594
## 30  2020-03-02 tot_deaths      153      162        9 0.05714286
## 31  2020-03-03 tot_deaths      156      165        9 0.05607477
## 32  2020-03-04 tot_deaths      158      167        9 0.05538462
## 33  2020-03-05 tot_deaths      160      169        9 0.05471125
## 34  2020-03-06 tot_deaths      163      172        9 0.05373134
## 35  2020-03-07 tot_deaths      168      177        9 0.05217391
## 36  2020-03-08 tot_deaths      173      182        9 0.05070423
## 37  2020-02-02  tot_cases      510      612      102 0.18181818
## 38  2020-02-03  tot_cases      542      644      102 0.17200675
## 39  2020-02-04  tot_cases      550      652      102 0.16971714
## 40  2020-02-05  tot_cases      555      657      102 0.16831683
## 41  2020-02-06  tot_cases      557      658      101 0.16625514
## 42  2020-02-07  tot_cases      562      663      101 0.16489796
## 43  2020-02-08  tot_cases      570      670      100 0.16129032
## 44  2020-02-09  tot_cases      605      705      100 0.15267176
## 45  2020-02-10  tot_cases      614      713       99 0.14920874
## 46  2020-02-11  tot_cases      625      721       96 0.14264487
## 47  2020-02-12  tot_cases      635      731       96 0.14055637
## 48  2020-02-13  tot_cases      641      736       95 0.13798112
## 49  2020-02-14  tot_cases      649      743       94 0.13505747
## 50  2020-02-15  tot_cases      654      748       94 0.13409415
## 51  2020-02-16  tot_cases      667      758       91 0.12771930
## 52  2020-02-17  tot_cases      685      776       91 0.12457221
## 53  2020-02-18  tot_cases      692      783       91 0.12338983
## 54  2020-02-19  tot_cases      709      799       90 0.11936340
## 55  2020-02-20  tot_cases      723      811       88 0.11473272
## 56  2020-02-21  tot_cases      742      829       87 0.11075748
## 57  2020-02-22  tot_cases      768      855       87 0.10720887
## 58  2020-02-23  tot_cases      792      877       85 0.10185740
## 59  2020-02-24  tot_cases      811      896       85 0.09958992
## 60  2020-02-25  tot_cases      835      920       85 0.09686610
## 61  2020-02-26  tot_cases      879      963       84 0.09120521
## 62  2020-02-27  tot_cases      916      998       82 0.08568443
## 63  2020-02-28  tot_cases      968     1049       81 0.08031730
## 64  2020-02-29  tot_cases     1005     1087       82 0.07839388
## 65  2020-03-01  tot_cases     1094     1177       83 0.07309555
## 66  2020-03-02  tot_cases     1172     1254       82 0.06760099
## 67  2020-03-03  tot_cases     1343     1424       81 0.05854716
## 68  2020-03-04  tot_cases     1482     1565       83 0.05447982
## 69  2021-07-05 new_deaths      104       37       67 0.95035461
## 70  2021-07-04 new_deaths       98       38       60 0.88235294
## 71  2021-01-18 new_deaths     2674     1130     1544 0.81177708
## 72  2021-07-03 new_deaths      140       86       54 0.47787611
## 73  2021-01-19 new_deaths     3036     4578     1542 0.40504334
## 74  2020-12-26 new_deaths     2248     3093      845 0.31642015
## 75  2020-12-24 new_deaths     3274     2463      811 0.28272616
## 76  2021-06-27 new_deaths      139      105       34 0.27868852
## 77  2021-06-20 new_deaths      176      145       31 0.19314642
## 78  2021-06-26 new_deaths      172      142       30 0.19108280
## 79  2021-06-19 new_deaths      180      154       26 0.15568862
## 80  2021-06-28 new_deaths      193      170       23 0.12672176
## 81  2021-06-24 new_deaths      287      258       29 0.10642202
## 82  2021-06-17 new_deaths      334      302       32 0.10062893
## 83  2021-06-23 new_deaths      310      281       29 0.09813875
## 84  2021-06-25 new_deaths      300      273       27 0.09424084
## 85  2021-06-22 new_deaths      283      258       25 0.09242144
## 86  2021-06-18 new_deaths      210      192       18 0.08955224
## 87  2021-06-13 new_deaths      200      184       16 0.08333333
## 88  2021-05-30 new_deaths      237      220       17 0.07439825
## 89  2020-03-21 new_deaths      114      107        7 0.06334842
## 90  2021-06-11 new_deaths      326      306       20 0.06329114
## 91  2021-06-16 new_deaths      310      293       17 0.05638474
## 92  2021-06-15 new_deaths      336      319       17 0.05190840
## 93  2020-02-02  new_cases        1      557      556 1.99283154
## 94  2021-07-05  new_cases    11563     3575     7988 1.05535738
## 95  2021-07-04  new_cases    12794     4156     8638 1.01923304
## 96  2021-07-03  new_cases    14978     5887     9091 0.87141145
## 97  2021-06-10  new_cases    16732    12363     4369 0.30032652
## 98  2021-01-18  new_cases   138853   107646    31207 0.25320184
## 99  2021-01-19  new_cases   145009   176292    31283 0.19472706
## 100 2021-07-02  new_cases    16830    14183     2647 0.17070261
## 101 2021-06-20  new_cases     9228     7787     1441 0.16937996
## 102 2020-12-24  new_cases   222824   195402    27422 0.13113484
## 103 2021-06-01  new_cases     9689     8540     1149 0.12606287
## 104 2021-01-29  new_cases   156344   139722    16622 0.11228577
## 105 2020-12-26  new_cases   151874   169350    17476 0.10880881
## 106 2021-06-30  new_cases    17295    15526     1769 0.10779684
## 107 2021-06-28  new_cases     9690     8701      989 0.10755261
## 108 2021-06-09  new_cases    19404    21526     2122 0.10368923
## 109 2021-01-09  new_cases   249812   226455    23357 0.09808364
## 110 2021-01-30  new_cases   137321   150808    13487 0.09361779
## 111 2021-07-01  new_cases    18730    17149     1581 0.08812955
## 112 2021-06-08  new_cases    14356    15667     1311 0.08733304
## 113 2021-06-29  new_cases    16159    15051     1108 0.07100288
## 114 2021-06-06  new_cases    12102    11304      798 0.06818764
## 115 2020-07-14  new_cases    65684    61818     3866 0.06064219
## 116 2021-01-08  new_cases   295289   312357    17068 0.05617745
## 117 2021-05-24  new_cases    15657    14828      829 0.05438740
## 118 2021-05-31  new_cases     9193     9700      507 0.05367067
## 119 2021-05-03  new_cases    33239    31601     1638 0.05052437
## 120 2021-06-07  new_cases    10122    10644      522 0.05027449
## 121 2020-07-15  new_cases    70320    73939     3619 0.05017365

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     IN tot_deaths   3407157   3378244    28913 0.008522120
## 2     SC tot_deaths   2291589   2305862    14273 0.006209093
## 3     CA tot_deaths  14183041  14129523    53518 0.003780512
## 4     NC tot_deaths   3073917   3062861    11056 0.003603194
## 5     MS tot_deaths   1998075   1991323     6752 0.003384972
## 6     KY tot_deaths   1634463   1630052     4411 0.002702392
## 7     RI tot_deaths    749883    751479     1596 0.002126070
## 8     NM tot_deaths   1001515    999916     1599 0.001597857
## 9     AL tot_deaths   2742024   2738028     3996 0.001458380
## 10    CA  tot_cases 865747767 837321729 28426038 0.033382123
## 11    SC  tot_cases 129358076 129977727   619651 0.004778754
## 12    RI  tot_cases  32453898  32591078   137180 0.004218004
## 13    AL  tot_cases 131847795 131406619   441176 0.003351708
## 14    MI  tot_cases 214132223 214386719   254496 0.001187793
## 15    MS  tot_cases  77187328  77104046    83282 0.001079542
## 16    MS new_deaths      7432      7332      100 0.013546464
## 17    NM new_deaths      4382      4344       38 0.008709603
## 18    CA new_deaths     63517     62992      525 0.008299805
## 19    KY new_deaths      7285      7229       56 0.007716687
## 20    NC new_deaths     13517     13434       83 0.006159326
## 21    AL new_deaths     11430     11360       70 0.006143045
## 22    MI new_deaths     21076     20995       81 0.003850633
## 23    IN new_deaths     13914     13863       51 0.003672103
## 24    TX new_deaths     51507     51349      158 0.003072256
## 25    TN new_deaths     12611     12576       35 0.002779211
## 26    WA new_deaths      5954      5939       15 0.002522492
## 27    RI new_deaths      2736      2730        6 0.002195390
## 28    UT new_deaths      2371      2368        3 0.001266090
## 29    CA  new_cases   3880232   3713944   166288 0.043793560
## 30    VI  new_cases      3932      3916       16 0.004077472
## 31    MS  new_cases    323003    321780     1223 0.003793524
## 32    AL  new_cases    554270    552325     1945 0.003515288
## 33    LA  new_cases    483605    482096     1509 0.003125191
## 34    NV  new_cases    335771    334763     1008 0.003006559
## 35    FL  new_cases   2344516   2337613     6903 0.002948659
## 36    WY  new_cases     62592     62445      147 0.002351304
## 37    UT  new_cases    416971    416110      861 0.002067026
## 38    KS  new_cases    319154    318515      639 0.002004175
## 39    WA  new_cases    453368    452483      885 0.001953964
## 40    AK  new_cases     68595     68478      117 0.001707120
## 41    MI  new_cases   1002081   1000375     1706 0.001703908
## 42    OR  new_cases    209377    209035      342 0.001634752
## 43    NC  new_cases   1015407   1014359     1048 0.001032631
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 33,360
## Columns: 15
## $ date           <date> 2021-02-02, 2020-07-30, 2020-05-03, 2020-12-04, 2021-0~
## $ state          <chr> "IL", "ME", "NH", "IN", "CA", "GU", "CT", "WI", "NV", "~
## $ tot_cases      <dbl> 1130917, 3910, 2518, 367338, 3409079, 0, 267337, 98440,~
## $ conf_cases     <dbl> 1130917, 3497, NA, NA, 3285871, NA, 250915, 92712, NA, ~
## $ prob_cases     <dbl> 0, 413, NA, NA, 123208, NA, 16422, 5728, NA, 105447, NA~
## $ new_cases      <dbl> 2304, 22, 89, 7899, 18703, 0, 0, 1502, 128, 199, 0, 394~
## $ pnew_case      <dbl> 0, 2, 0, 0, 892, NA, 0, 94, 0, 47, NA, 5, 102, NA, 0, 0~
## $ tot_deaths     <dbl> 21336, 123, 86, 7031, 49603, 0, 7381, 1237, 5586, 21047~
## $ conf_death     <dbl> 19306, 122, NA, 6746, 49603, NA, 6049, 1228, NA, 19789,~
## $ prob_death     <dbl> 2030, 1, NA, 285, 0, NA, 1332, 9, NA, 1258, NA, NA, 0, ~
## $ new_deaths     <dbl> 63, 2, 2, 91, 494, 0, 0, 8, 0, 6, 0, 32, 60, 6, 2, 39, ~
## $ pnew_death     <dbl> 16, 0, 0, 1, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 7, 0, ~
## $ created_at     <chr> "02/03/2021 02:55:58 PM", "07/31/2020 02:35:06 PM", "05~
## $ consent_cases  <chr> "Agree", "Agree", "Not agree", "Not agree", "Agree", "N~
## $ consent_deaths <chr> "Agree", "Agree", "Not agree", "Agree", "Agree", "Not a~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_210801.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 28
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta   pctDelta
## 1 2021-07-02 hosp_ped      662      597       65 0.10325655
## 2 2021-07-03 hosp_ped      638      597       41 0.06639676

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL        inp   523814   518483     5331 0.010229330
## 2     TN        inp   558512   559654     1142 0.002042631
## 3     NM        inp   137802   137991      189 0.001370593
## 4     NH   hosp_ped      271      361       90 0.284810127
## 5     ME   hosp_ped      452      509       57 0.118626431
## 6     KY   hosp_ped     5518     5308      210 0.038795492
## 7     MA   hosp_ped     5015     5201      186 0.036413469
## 8     AR   hosp_ped     5977     5840      137 0.023186934
## 9     TN   hosp_ped     7924     8102      178 0.022213902
## 10    DE   hosp_ped     1647     1683       36 0.021621622
## 11    AL   hosp_ped     7711     7555      156 0.020437574
## 12    WV   hosp_ped     2226     2269       43 0.019132369
## 13    KS   hosp_ped     1711     1679       32 0.018879056
## 14    NV   hosp_ped     1999     2037       38 0.018830525
## 15    AZ   hosp_ped    11435    11266      169 0.014889212
## 16    VA   hosp_ped     6604     6513       91 0.013875124
## 17    IN   hosp_ped     6913     6826       87 0.012664677
## 18    MS   hosp_ped     3727     3686       41 0.011061648
## 19    MO   hosp_ped    15406    15241      165 0.010767775
## 20    SC   hosp_ped     2706     2679       27 0.010027855
## 21    PA   hosp_ped    19857    20010      153 0.007675521
## 22    WA   hosp_ped     4288     4263       25 0.005847269
## 23    NM   hosp_ped     3125     3107       18 0.005776637
## 24    IA   hosp_ped     2275     2287       12 0.005260851
## 25    CO   hosp_ped     9355     9401       46 0.004905097
## 26    NJ   hosp_ped     9108     9142       34 0.003726027
## 27    OH   hosp_ped    25500    25406       94 0.003693081
## 28    IL   hosp_ped    19711    19644       67 0.003404904
## 29    GA   hosp_ped    21902    21973       71 0.003236467
## 30    MT   hosp_ped     1022     1025        3 0.002931119
## 31    PR   hosp_ped    11353    11380       27 0.002375401
## 32    CA   hosp_ped    30719    30667       52 0.001694197
## 33    LA   hosp_ped     3174     3179        5 0.001574059
## 34    TX   hosp_ped    38680    38739       59 0.001524174
## 35    FL   hosp_ped    54840    54921       81 0.001475934
## 36    HI   hosp_ped      720      721        1 0.001387925
## 37    NC   hosp_ped    10619    10606       13 0.001224971
## 38    AL hosp_adult   443621   439848     3773 0.008541330
## 39    TN hosp_adult   494022   494969      947 0.001915083
## 40    NM hosp_adult   112634   112842      208 0.001844986
## 41    ME hosp_adult    37173    37121       52 0.001399844
## 42    WV hosp_adult   126618   126444      174 0.001375157
## 43    KY hosp_adult   299353   299757      404 0.001348667
## 44    NH hosp_adult    39064    39014       50 0.001280771
## 45    CA hosp_adult  2422197  2425080     2883 0.001189534
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 27,682
## Columns: 99
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_210801.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 4
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 14,918
## Columns: 69
## $ date                                   <date> 2021-07-31, 2021-07-31, 2021-0~
## $ MMWR_week                              <dbl> 30, 30, 30, 30, 30, 30, 30, 30,~
## $ state                                  <chr> "AK", "NM", "PR", "RP", "MS", "~
## $ Distributed                            <dbl> 854805, 2449685, 4266370, 28650~
## $ Distributed_Janssen                    <dbl> 59300, 138500, 190000, 3800, 16~
## $ Distributed_Moderna                    <dbl> 366220, 1066860, 1853400, 20800~
## $ Distributed_Pfizer                     <dbl> 429285, 1244325, 2222970, 4050,~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 116849, 116828, 133587, 159993,~
## $ Distributed_Per_100k_12Plus            <dbl> 140390, 137051, 149787, 187353,~
## $ Distributed_Per_100k_18Plus            <dbl> 154979, 151123, 162779, 205421,~
## $ Distributed_Per_100k_65Plus            <dbl> 933315, 648741, 785808, 944298,~
## $ vxa                                    <dbl> 697440, 2487536, 3975244, 26286~
## $ Administered_12Plus                    <dbl> 695366, 2487278, 3973905, 26286~
## $ Administered_18Plus                    <dbl> 653874, 2330829, 3705211, 25597~
## $ Administered_65Plus                    <dbl> 143058, 664378, 1048492, 3120, ~
## $ Administered_Janssen                   <dbl> 28437, 87616, 114212, 2145, 637~
## $ Administered_Moderna                   <dbl> 289116, 1081538, 1691040, 23441~
## $ Administered_Pfizer                    <dbl> 379706, 1313894, 2169642, 700, ~
## $ Administered_Unk_Manuf                 <dbl> 181, 4488, 350, 0, 1047, 727, 0~
## $ Administered_Fed_LTC                   <dbl> 6640, 39710, 74284, 0, 54224, 1~
## $ Administered_Fed_LTC_Residents         <dbl> 2078, 11847, 11431, 0, 26288, 8~
## $ Administered_Fed_LTC_Staff             <dbl> 1378, 12139, 10950, 0, 12915, 5~
## $ Administered_Fed_LTC_Unk               <dbl> 3184, 15724, 51903, 0, 15021, 3~
## $ Administered_Fed_LTC_Dose1             <dbl> 4300, 24065, 53094, 0, 31843, 1~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 1383, 6414, 7925, 0, 14433, 507~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 956, 6649, 7461, 0, 7685, 36183~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 1961, 11002, 37708, 0, 9725, 29~
## $ Admin_Per_100k                         <dbl> 95338, 118633, 124472, 146792, ~
## $ Admin_Per_100k_12Plus                  <dbl> 114205, 139154, 139519, 171894,~
## $ Admin_Per_100k_18Plus                  <dbl> 118550, 143790, 141368, 183531,~
## $ Admin_Per_100k_65Plus                  <dbl> 156197, 175945, 193118, 102835,~
## $ Recip_Administered                     <dbl> 692140, 2511859, 4003254, 26519~
## $ Administered_Dose1_Recip               <dbl> 376882, 1374231, 2197391, 15199~
## $ Administered_Dose1_Pop_Pct             <dbl> 51.5, 65.5, 68.8, 84.9, 39.8, 5~
## $ Administered_Dose1_Recip_12Plus        <dbl> 375603, 1373997, 2196318, 15199~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 61.7, 76.9, 77.1, 99.4, 46.9, 6~
## $ Administered_Dose1_Recip_18Plus        <dbl> 352303, 1282733, 2045507, 14508~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 63.9, 79.1, 78.0, 99.9, 50.0, 6~
## $ Administered_Dose1_Recip_65Plus        <dbl> 75867, 359328, 564728, 1707, 38~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 82.8, 95.2, 99.9, 56.3, 78.6, 9~
## $ vxc                                    <dbl> 333092, 1198386, 1911719, 13461~
## $ vxcpoppct                              <dbl> 45.5, 57.2, 59.9, 75.2, 34.5, 5~
## $ Series_Complete_12Plus                 <dbl> 332299, 1198314, 1911408, 13461~
## $ Series_Complete_12PlusPop_Pct          <dbl> 54.6, 67.0, 67.1, 88.0, 40.7, 6~
## $ vxcgte18                               <dbl> 314089, 1126808, 1790751, 13461~
## $ vxcgte18pct                            <dbl> 56.9, 69.5, 68.3, 96.5, 44.0, 6~
## $ vxcgte65                               <dbl> 71390, 324959, 506358, 1671, 35~
## $ vxcgte65pct                            <dbl> 77.9, 86.1, 93.3, 55.1, 72.7, 8~
## $ Series_Complete_Janssen                <dbl> 26386, 86064, 113821, 2148, 627~
## $ Series_Complete_Moderna                <dbl> 133838, 492367, 784508, 11283, ~
## $ Series_Complete_Pfizer                 <dbl> 172824, 618609, 1013352, 30, 52~
## $ Series_Complete_Unk_Manuf              <dbl> 44, 1346, 38, 0, 138, 318, 0, 1~
## $ Series_Complete_Janssen_12Plus         <dbl> 26384, 86052, 113778, 2148, 627~
## $ Series_Complete_Moderna_12Plus         <dbl> 133834, 492349, 784456, 11283, ~
## $ Series_Complete_Pfizer_12Plus          <dbl> 172037, 618567, 1013136, 30, 52~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 44, 1346, 38, 0, 138, 318, 0, 1~
## $ Series_Complete_Janssen_18Plus         <dbl> 26261, 85937, 113673, 2148, 626~
## $ Series_Complete_Moderna_18Plus         <dbl> 133469, 492021, 784182, 11283, ~
## $ Series_Complete_Pfizer_18Plus          <dbl> 154318, 547516, 892859, 30, 495~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 41, 1334, 37, 0, 133, 309, 0, 1~
## $ Series_Complete_Janssen_65Plus         <dbl> 2638, 18271, 19965, 212, 15374,~
## $ Series_Complete_Moderna_65Plus         <dbl> 40125, 151102, 257623, 1450, 18~
## $ Series_Complete_Pfizer_65Plus          <dbl> 28605, 154857, 228764, 9, 15393~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 22, 729, 6, 0, 60, 135, 0, 734,~
## $ Series_Complete_FedLTC                 <dbl> 2320, 15515, 21185, 0, 22390, 6~
## $ Series_Complete_FedLTC_Residents       <dbl> 676, 5246, 3503, 0, 11688, 3467~
## $ Series_Complete_FedLTC_Staff           <dbl> 425, 5319, 3488, 0, 5176, 23209~
## $ Series_Complete_FedLTC_Unknown         <dbl> 1219, 4950, 14194, 0, 5526, 782~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before   8.21e+9    1.64e+8   3.49e+7 604596       32804    
## 2 after    8.17e+9    1.63e+8   3.47e+7 601834       28356    
## 3 pctchg   4.40e-3    3.96e-3   4.58e-3      0.00457     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 28,356
## Columns: 6
## $ date       <date> 2021-02-02, 2020-07-30, 2020-05-03, 2020-12-04, 2021-01-28~
## $ state      <chr> "IL", "ME", "NH", "IN", "CA", "CT", "WI", "NV", "MI", "MI",~
## $ tot_cases  <dbl> 1130917, 3910, 2518, 367338, 3409079, 267337, 98440, 324132~
## $ tot_deaths <dbl> 21336, 123, 86, 7031, 49603, 7381, 1237, 5586, 21047, 0, 11~
## $ new_cases  <dbl> 2304, 22, 89, 7899, 18703, 0, 1502, 128, 199, 0, 394, 3436,~
## $ new_deaths <dbl> 63, 2, 2, 91, 494, 0, 8, 0, 6, 0, 32, 60, 6, 2, 39, 66, 0, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 2.78e+7    2.19e+7 471723      27682     
## 2 after  2.77e+7    2.18e+7 459822      26679     
## 3 pctchg 5.58e-3    5.57e-3      0.0252     0.0362
## 
## 
## Processed for cdcHosp:
## Rows: 26,679
## Columns: 5
## $ date       <date> 2020-07-22, 2020-07-20, 2020-07-19, 2020-07-18, 2020-07-18~
## $ state      <chr> "IA", "IA", "ND", "IA", "ND", "TX", "OK", "CT", "ND", "NM",~
## $ inp        <dbl> 0, 1, 46, 10, 33, 12003, 678, 215, 16, 119, 51, 19, 250, 14~
## $ hosp_adult <dbl> 0, 1, NA, 10, NA, 7999, 566, 115, NA, NA, NA, NA, NA, NA, N~
## $ hosp_ped   <dbl> 0, 0, NA, 0, NA, 194, 9, 0, NA, NA, NA, NA, NA, NA, NA, NA,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 8.19e+10 3.37e+10 302401.    1.10e+10 561791.     3.28e+10  373517.   
## 2 after  3.89e+10 1.63e+10 255914.    5.34e+ 9 512134.     1.59e+10  320269.   
## 3 pctchg 5.24e- 1 5.16e- 1      0.154 5.16e- 1      0.0884 5.16e- 1       0.143
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 11,730
## Columns: 9
## $ date        <date> 2021-07-31, 2021-07-31, 2021-07-31, 2021-07-31, 2021-07-3~
## $ state       <chr> "AK", "NM", "MS", "WI", "NY", "OK", "MD", "NH", "WV", "AL"~
## $ vxa         <dbl> 697440, 2487536, 2150026, 6163565, 22950250, 3460262, 7213~
## $ vxc         <dbl> 333092, 1198386, 1026837, 3015017, 11109858, 1593194, 3559~
## $ vxcpoppct   <dbl> 45.5, 57.2, 34.5, 51.8, 57.1, 40.3, 58.9, 58.3, 39.0, 34.3~
## $ vxcgte65    <dbl> 71390, 324959, 353642, 895738, 2663975, 482309, 844122, 22~
## $ vxcgte65pct <dbl> 77.9, 86.1, 72.7, 88.1, 80.8, 75.9, 88.0, 87.4, 70.2, 69.5~
## $ vxcgte18    <dbl> 314089, 1126808, 1001545, 2875753, 10577357, 1533309, 3342~
## $ vxcgte18pct <dbl> 56.9, 69.5, 44.0, 63.1, 68.6, 51.0, 71.0, 68.2, 46.9, 43.1~
## 
## Integrated per capita data file:
## Rows: 28,569
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

all.equal(names(cdc_daily_210801_test), names(readFromRDS("cdc_daily_210801")))
## [1] TRUE
sapply(names(cdc_daily_210801_test), FUN=function(x)
    identical(cdc_daily_210801_test[[x]], readFromRDS("cdc_daily_210801")[[x]])
    )
##    stateData        dfRaw    dfProcess  dfPerCapita  useClusters plotDataList 
##         TRUE         TRUE         TRUE         TRUE         TRUE        FALSE
sapply(names(cdc_daily_210801_test$plotDataList), FUN=function(x)
    identical(cdc_daily_210801_test$plotDataList[[x]], readFromRDS("cdc_daily_210801")$plotDataList[[x]])
    )
##       dfFull        dfAgg plotClusters summaryPlots     detPlots 
##         TRUE         TRUE         TRUE        FALSE        FALSE

As expected, all data elements are identical. Plot environments change with each creation, so the plot objects are not identical.

The latest data are downloaded and processed, with caching to avoid multiple file downloads:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_210804.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_210804.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_210804.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210708")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210708")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210728_vaxonly")$dfRaw$vax
                    )

cdc_daily_210804 <- readRunCDCDaily(thruLabel="Aug 3, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_210804.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 28
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths      143      152        9 0.06101695
## 2   2020-02-03 tot_deaths      143      152        9 0.06101695
## 3   2020-02-04 tot_deaths      143      152        9 0.06101695
## 4   2020-02-05 tot_deaths      143      152        9 0.06101695
## 5   2020-02-06 tot_deaths      143      152        9 0.06101695
## 6   2020-02-07 tot_deaths      143      152        9 0.06101695
## 7   2020-02-08 tot_deaths      144      153        9 0.06060606
## 8   2020-02-09 tot_deaths      144      153        9 0.06060606
## 9   2020-02-10 tot_deaths      144      153        9 0.06060606
## 10  2020-02-11 tot_deaths      144      153        9 0.06060606
## 11  2020-02-12 tot_deaths      144      153        9 0.06060606
## 12  2020-02-13 tot_deaths      144      153        9 0.06060606
## 13  2020-02-14 tot_deaths      144      153        9 0.06060606
## 14  2020-02-15 tot_deaths      144      153        9 0.06060606
## 15  2020-02-16 tot_deaths      144      153        9 0.06060606
## 16  2020-02-17 tot_deaths      144      153        9 0.06060606
## 17  2020-02-18 tot_deaths      144      153        9 0.06060606
## 18  2020-02-19 tot_deaths      145      154        9 0.06020067
## 19  2020-02-20 tot_deaths      145      154        9 0.06020067
## 20  2020-02-21 tot_deaths      145      154        9 0.06020067
## 21  2020-02-22 tot_deaths      145      154        9 0.06020067
## 22  2020-02-23 tot_deaths      145      154        9 0.06020067
## 23  2020-02-24 tot_deaths      145      154        9 0.06020067
## 24  2020-02-25 tot_deaths      145      154        9 0.06020067
## 25  2020-02-26 tot_deaths      145      154        9 0.06020067
## 26  2020-02-27 tot_deaths      146      155        9 0.05980066
## 27  2020-02-28 tot_deaths      146      155        9 0.05980066
## 28  2020-02-29 tot_deaths      147      156        9 0.05940594
## 29  2020-03-01 tot_deaths      147      156        9 0.05940594
## 30  2020-03-02 tot_deaths      153      162        9 0.05714286
## 31  2020-03-03 tot_deaths      156      165        9 0.05607477
## 32  2020-03-04 tot_deaths      158      167        9 0.05538462
## 33  2020-03-05 tot_deaths      160      169        9 0.05471125
## 34  2020-03-06 tot_deaths      163      172        9 0.05373134
## 35  2020-03-07 tot_deaths      168      177        9 0.05217391
## 36  2020-03-08 tot_deaths      173      182        9 0.05070423
## 37  2020-02-02  tot_cases      510      612      102 0.18181818
## 38  2020-02-03  tot_cases      542      644      102 0.17200675
## 39  2020-02-04  tot_cases      550      652      102 0.16971714
## 40  2020-02-05  tot_cases      555      657      102 0.16831683
## 41  2020-02-06  tot_cases      557      658      101 0.16625514
## 42  2020-02-07  tot_cases      562      663      101 0.16489796
## 43  2020-02-08  tot_cases      570      670      100 0.16129032
## 44  2020-02-09  tot_cases      605      705      100 0.15267176
## 45  2020-02-10  tot_cases      614      713       99 0.14920874
## 46  2020-02-11  tot_cases      625      721       96 0.14264487
## 47  2020-02-12  tot_cases      635      731       96 0.14055637
## 48  2020-02-13  tot_cases      641      736       95 0.13798112
## 49  2020-02-14  tot_cases      649      743       94 0.13505747
## 50  2020-02-15  tot_cases      654      748       94 0.13409415
## 51  2020-02-16  tot_cases      667      758       91 0.12771930
## 52  2020-02-17  tot_cases      685      776       91 0.12457221
## 53  2020-02-18  tot_cases      692      783       91 0.12338983
## 54  2020-02-19  tot_cases      709      799       90 0.11936340
## 55  2020-02-20  tot_cases      723      811       88 0.11473272
## 56  2020-02-21  tot_cases      742      829       87 0.11075748
## 57  2020-02-22  tot_cases      768      855       87 0.10720887
## 58  2020-02-23  tot_cases      792      877       85 0.10185740
## 59  2020-02-24  tot_cases      811      896       85 0.09958992
## 60  2020-02-25  tot_cases      835      920       85 0.09686610
## 61  2020-02-26  tot_cases      879      963       84 0.09120521
## 62  2020-02-27  tot_cases      916      998       82 0.08568443
## 63  2020-02-28  tot_cases      968     1049       81 0.08031730
## 64  2020-02-29  tot_cases     1005     1087       82 0.07839388
## 65  2020-03-01  tot_cases     1094     1177       83 0.07309555
## 66  2020-03-02  tot_cases     1172     1254       82 0.06760099
## 67  2020-03-03  tot_cases     1343     1424       81 0.05854716
## 68  2020-03-04  tot_cases     1482     1565       83 0.05447982
## 69  2021-07-05 new_deaths      106       37       69 0.96503497
## 70  2021-07-04 new_deaths      101       38       63 0.90647482
## 71  2021-01-18 new_deaths     2674     1130     1544 0.81177708
## 72  2021-07-03 new_deaths      142       86       56 0.49122807
## 73  2021-01-19 new_deaths     3036     4578     1542 0.40504334
## 74  2020-12-26 new_deaths     2248     3093      845 0.31642015
## 75  2020-12-24 new_deaths     3274     2463      811 0.28272616
## 76  2021-06-27 new_deaths      139      105       34 0.27868852
## 77  2021-06-26 new_deaths      175      142       33 0.20820189
## 78  2021-06-20 new_deaths      177      145       32 0.19875776
## 79  2021-06-19 new_deaths      180      154       26 0.15568862
## 80  2021-06-28 new_deaths      193      170       23 0.12672176
## 81  2021-06-24 new_deaths      287      258       29 0.10642202
## 82  2021-06-17 new_deaths      334      302       32 0.10062893
## 83  2021-06-23 new_deaths      310      281       29 0.09813875
## 84  2021-06-25 new_deaths      300      273       27 0.09424084
## 85  2021-06-22 new_deaths      283      258       25 0.09242144
## 86  2021-06-18 new_deaths      210      192       18 0.08955224
## 87  2021-06-13 new_deaths      200      184       16 0.08333333
## 88  2021-05-30 new_deaths      237      220       17 0.07439825
## 89  2020-03-21 new_deaths      114      107        7 0.06334842
## 90  2021-06-11 new_deaths      326      306       20 0.06329114
## 91  2021-06-16 new_deaths      310      293       17 0.05638474
## 92  2021-06-15 new_deaths      336      319       17 0.05190840
## 93  2020-02-02  new_cases        1      557      556 1.99283154
## 94  2021-07-05  new_cases    11586     3575     8011 1.05679045
## 95  2021-07-04  new_cases    12813     4156     8657 1.02033119
## 96  2021-07-03  new_cases    14988     5887     9101 0.87195210
## 97  2021-06-10  new_cases    16732    12363     4369 0.30032652
## 98  2021-01-18  new_cases   138860   107646    31214 0.25325144
## 99  2021-01-19  new_cases   145017   176292    31275 0.19467242
## 100 2021-07-02  new_cases    16845    14183     2662 0.17158695
## 101 2021-06-20  new_cases     9238     7787     1451 0.17045521
## 102 2020-12-24  new_cases   222830   195402    27428 0.13116165
## 103 2021-06-01  new_cases     9691     8540     1151 0.12626844
## 104 2021-01-29  new_cases   156346   139722    16624 0.11229853
## 105 2020-12-26  new_cases   151877   169350    17473 0.10878911
## 106 2021-06-30  new_cases    17308    15526     1782 0.10854602
## 107 2021-06-28  new_cases     9695     8701      994 0.10806697
## 108 2021-06-09  new_cases    19405    21526     2121 0.10363783
## 109 2021-01-09  new_cases   249814   226455    23359 0.09809162
## 110 2021-01-30  new_cases   137320   150808    13488 0.09362506
## 111 2021-07-01  new_cases    18738    17149     1589 0.08855574
## 112 2021-06-08  new_cases    14357    15667     1310 0.08726352
## 113 2021-06-29  new_cases    16174    15051     1123 0.07192954
## 114 2021-06-06  new_cases    12103    11304      799 0.06827018
## 115 2020-07-14  new_cases    65688    61818     3870 0.06070303
## 116 2021-01-08  new_cases   295299   312357    17058 0.05614361
## 117 2021-05-24  new_cases    15656    14828      828 0.05432358
## 118 2021-05-31  new_cases     9193     9700      507 0.05367067
## 119 2021-05-03  new_cases    33241    31601     1640 0.05058450
## 120 2020-07-15  new_cases    70325    73939     3614 0.05010259

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     IN tot_deaths   3407157   3378244    28913 0.008522120
## 2     SC tot_deaths   2291589   2305862    14273 0.006209093
## 3     CA tot_deaths  14183041  14129523    53518 0.003780512
## 4     NC tot_deaths   3073917   3062861    11056 0.003603194
## 5     MS tot_deaths   1998075   1991323     6752 0.003384972
## 6     KY tot_deaths   1634463   1630052     4411 0.002702392
## 7     AL tot_deaths   2743934   2738028     5906 0.002154703
## 8     RI tot_deaths    749883    751479     1596 0.002126070
## 9     NM tot_deaths   1001515    999916     1599 0.001597857
## 10    CA  tot_cases 865747767 837321729 28426038 0.033382123
## 11    AL  tot_cases 132184325 131406619   777706 0.005900855
## 12    SC  tot_cases 129358076 129977727   619651 0.004778754
## 13    RI  tot_cases  32450790  32591078   140288 0.004313775
## 14    MI  tot_cases 214132223 214386719   254496 0.001187793
## 15    MS  tot_cases  77187328  77104046    83282 0.001079542
## 16    MS new_deaths      7432      7332      100 0.013546464
## 17    NM new_deaths      4382      4344       38 0.008709603
## 18    CA new_deaths     63517     62992      525 0.008299805
## 19    AL new_deaths     11454     11360       94 0.008240554
## 20    KY new_deaths      7285      7229       56 0.007716687
## 21    NC new_deaths     13517     13434       83 0.006159326
## 22    MI new_deaths     21076     20995       81 0.003850633
## 23    IN new_deaths     13914     13863       51 0.003672103
## 24    TX new_deaths     51507     51349      158 0.003072256
## 25    TN new_deaths     12611     12576       35 0.002779211
## 26    WA new_deaths      5954      5939       15 0.002522492
## 27    RI new_deaths      2736      2730        6 0.002195390
## 28    UT new_deaths      2371      2368        3 0.001266090
## 29    CA  new_cases   3880232   3713944   166288 0.043793560
## 30    AL  new_cases    555727    552325     3402 0.006140506
## 31    VI  new_cases      3932      3916       16 0.004077472
## 32    MS  new_cases    323003    321780     1223 0.003793524
## 33    LA  new_cases    483605    482096     1509 0.003125191
## 34    NV  new_cases    335771    334763     1008 0.003006559
## 35    FL  new_cases   2344516   2337613     6903 0.002948659
## 36    WY  new_cases     62592     62445      147 0.002351304
## 37    UT  new_cases    416971    416110      861 0.002067026
## 38    KS  new_cases    319154    318515      639 0.002004175
## 39    WA  new_cases    453368    452483      885 0.001953964
## 40    AK  new_cases     68595     68478      117 0.001707120
## 41    MI  new_cases   1002081   1000375     1706 0.001703908
## 42    OR  new_cases    209377    209035      342 0.001634752
## 43    NC  new_cases   1015407   1014359     1048 0.001032631
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 33,540
## Columns: 15
## $ date           <date> 2021-02-12, 2020-07-28, 2020-08-22, 2020-10-22, 2020-0~
## $ state          <chr> "UT", "MP", "AR", "MP", "AS", "HI", "AK", "TX", "NYC", ~
## $ tot_cases      <dbl> 359641, 40, 56199, 88, 0, 661, 71521, 1867163, 948436, ~
## $ conf_cases     <dbl> 359641, 40, NA, 88, NA, NA, NA, NA, 782257, NA, 106, NA~
## $ prob_cases     <dbl> 0, 0, NA, 0, NA, NA, NA, NA, 166179, NA, 0, NA, 0, 4003~
## $ new_cases      <dbl> 1060, 0, 547, 0, 0, 8, 235, 24010, 394, 18811, 0, 0, 11~
## $ pnew_case      <dbl> 0, 0, 0, 0, 0, 0, 0, 4196, 95, 3202, 0, 0, 0, 197, 0, 0~
## $ tot_deaths     <dbl> 1785, 2, 674, 2, 0, 17, 377, 33124, 33203, 23357, 2, 0,~
## $ conf_death     <dbl> 1729, 2, NA, 2, NA, NA, NA, NA, 28130, NA, 2, NA, NA, 1~
## $ prob_death     <dbl> 56, 0, NA, 0, NA, NA, NA, NA, 5073, NA, 0, NA, NA, 350,~
## $ new_deaths     <dbl> 11, 0, 11, 0, 0, 0, 0, 345, 6, 190, 0, 0, 7, 8, 5, 0, 1~
## $ pnew_death     <dbl> 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, 0, 0, 0, 0, 0, ~
## $ created_at     <chr> "02/13/2021 02:50:08 PM", "07/29/2020 02:34:46 PM", "08~
## $ consent_cases  <chr> "Agree", "Agree", "Not agree", "Agree", NA, "Not agree"~
## $ consent_deaths <chr> "Agree", "Agree", "Not agree", "Agree", NA, "Not agree"~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_210804.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 28
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta   pctDelta
## 1 2021-07-02 hosp_ped      662      597       65 0.10325655
## 2 2021-07-03 hosp_ped      638      597       41 0.06639676

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL        inp   523814   518483     5331 0.010229330
## 2     TN        inp   558512   559654     1142 0.002042631
## 3     NM        inp   137802   137991      189 0.001370593
## 4     NH   hosp_ped      271      361       90 0.284810127
## 5     ME   hosp_ped      452      509       57 0.118626431
## 6     KY   hosp_ped     5518     5308      210 0.038795492
## 7     MA   hosp_ped     5015     5201      186 0.036413469
## 8     AR   hosp_ped     5977     5840      137 0.023186934
## 9     TN   hosp_ped     7924     8102      178 0.022213902
## 10    DE   hosp_ped     1647     1683       36 0.021621622
## 11    AL   hosp_ped     7711     7555      156 0.020437574
## 12    WV   hosp_ped     2226     2269       43 0.019132369
## 13    KS   hosp_ped     1711     1679       32 0.018879056
## 14    NV   hosp_ped     1999     2037       38 0.018830525
## 15    AZ   hosp_ped    11435    11266      169 0.014889212
## 16    VA   hosp_ped     6604     6513       91 0.013875124
## 17    IN   hosp_ped     6913     6826       87 0.012664677
## 18    MS   hosp_ped     3727     3686       41 0.011061648
## 19    MO   hosp_ped    15406    15241      165 0.010767775
## 20    SC   hosp_ped     2706     2679       27 0.010027855
## 21    PA   hosp_ped    19857    20010      153 0.007675521
## 22    WA   hosp_ped     4288     4263       25 0.005847269
## 23    NM   hosp_ped     3125     3107       18 0.005776637
## 24    IA   hosp_ped     2275     2287       12 0.005260851
## 25    CO   hosp_ped     9355     9401       46 0.004905097
## 26    NJ   hosp_ped     9108     9142       34 0.003726027
## 27    OH   hosp_ped    25500    25406       94 0.003693081
## 28    IL   hosp_ped    19711    19644       67 0.003404904
## 29    GA   hosp_ped    21902    21973       71 0.003236467
## 30    MT   hosp_ped     1022     1025        3 0.002931119
## 31    PR   hosp_ped    11353    11380       27 0.002375401
## 32    CA   hosp_ped    30719    30667       52 0.001694197
## 33    LA   hosp_ped     3174     3179        5 0.001574059
## 34    TX   hosp_ped    38680    38739       59 0.001524174
## 35    FL   hosp_ped    54840    54921       81 0.001475934
## 36    HI   hosp_ped      720      721        1 0.001387925
## 37    NC   hosp_ped    10619    10606       13 0.001224971
## 38    AL hosp_adult   443621   439848     3773 0.008541330
## 39    TN hosp_adult   494022   494969      947 0.001915083
## 40    NM hosp_adult   112634   112842      208 0.001844986
## 41    ME hosp_adult    37173    37121       52 0.001399844
## 42    WV hosp_adult   126618   126444      174 0.001375157
## 43    KY hosp_adult   299353   299757      404 0.001348667
## 44    NH hosp_adult    39064    39014       50 0.001280771
## 45    CA hosp_adult  2422197  2425080     2883 0.001189534
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 27,682
## Columns: 99
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_210804.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 7
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 15,113
## Columns: 69
## $ date                                   <date> 2021-08-03, 2021-08-03, 2021-0~
## $ MMWR_week                              <dbl> 31, 31, 31, 31, 31, 31, 31, 31,~
## $ state                                  <chr> "MH", "MN", "AL", "MD", "NC", "~
## $ Distributed                            <dbl> 51300, 6729450, 5167970, 880302~
## $ Distributed_Janssen                    <dbl> 10800, 349300, 281300, 440400, ~
## $ Distributed_Moderna                    <dbl> 40500, 2700980, 2377380, 345114~
## $ Distributed_Pfizer                     <dbl> 0, 3679170, 2509290, 4911480, 6~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 87823, 119324, 105400, 145608, ~
## $ Distributed_Per_100k_12Plus            <dbl> 102839, 140840, 123432, 170506,~
## $ Distributed_Per_100k_18Plus            <dbl> 112755, 155182, 135469, 186861,~
## $ Distributed_Per_100k_65Plus            <dbl> 518339, 731158, 608113, 917559,~
## $ vxa                                    <dbl> 36161, 6102310, 3634744, 723766~
## $ Administered_12Plus                    <dbl> 36132, 6082956, 3634417, 723724~
## $ Administered_18Plus                    <dbl> 36069, 5709218, 3515687, 675157~
## $ Administered_65Plus                    <dbl> 2101, 1599519, 1225637, 1686839~
## $ Administered_Janssen                   <dbl> 1206, 273277, 121830, 277559, 3~
## $ Administered_Moderna                   <dbl> 34955, 2359899, 1661529, 276459~
## $ Administered_Pfizer                    <dbl> 0, 3468298, 1851381, 4186640, 5~
## $ Administered_Unk_Manuf                 <dbl> 0, 836, 4, 8864, 457, 36, 565, ~
## $ Administered_Fed_LTC                   <dbl> 0, 176248, 90554, 195303, 22810~
## $ Administered_Fed_LTC_Residents         <dbl> 0, 73383, 48060, 94356, 112427,~
## $ Administered_Fed_LTC_Staff             <dbl> 0, 70268, 32757, 74670, 73173, ~
## $ Administered_Fed_LTC_Unk               <dbl> 0, 32597, 9737, 26277, 42502, 2~
## $ Administered_Fed_LTC_Dose1             <dbl> 0, 107732, 55156, 115925, 13667~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 0, 43418, 28477, 52713, 63620, ~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 0, 41574, 20542, 43429, 42856, ~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 0, 22740, 6137, 19783, 30194, 1~
## $ Admin_Per_100k                         <dbl> 61906, 108204, 74130, 119716, 9~
## $ Admin_Per_100k_12Plus                  <dbl> 72432, 127309, 86805, 140178, 1~
## $ Admin_Per_100k_18Plus                  <dbl> 79278, 131656, 92157, 143315, 1~
## $ Admin_Per_100k_65Plus                  <dbl> 21229, 173789, 144220, 175823, ~
## $ Recip_Administered                     <dbl> 36214, 6130082, 3736050, 728051~
## $ Administered_Dose1_Recip               <dbl> 19994, 3333060, 2154479, 392978~
## $ Administered_Dose1_Pop_Pct             <dbl> 34.2, 59.1, 43.9, 65.0, 51.6, 5~
## $ Administered_Dose1_Recip_12Plus        <dbl> 19973, 3321978, 2154149, 392930~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 40.0, 69.5, 51.4, 76.1, 60.1, 6~
## $ Administered_Dose1_Recip_18Plus        <dbl> 19925, 3123896, 2075040, 366521~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 43.8, 72.0, 54.4, 77.8, 62.5, 6~
## $ Administered_Dose1_Recip_65Plus        <dbl> 1157, 852313, 690242, 895212, 1~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 11.7, 92.6, 81.2, 93.3, 84.6, 9~
## $ vxc                                    <dbl> 17307, 3040861, 1693504, 356886~
## $ vxcpoppct                              <dbl> 29.6, 53.9, 34.5, 59.0, 43.9, 4~
## $ Series_Complete_12Plus                 <dbl> 17298, 3032831, 1693466, 356870~
## $ Series_Complete_12PlusPop_Pct          <dbl> 34.7, 63.5, 40.4, 69.1, 51.2, 5~
## $ vxcgte18                               <dbl> 17275, 2858303, 1652134, 335011~
## $ vxcgte18pct                            <dbl> 38.0, 65.9, 43.3, 71.1, 53.6, 5~
## $ vxcgte65                               <dbl> 1008, 801731, 591426, 844755, 1~
## $ vxcgte65pct                            <dbl> 10.2, 87.1, 69.6, 88.1, 77.2, 8~
## $ Series_Complete_Janssen                <dbl> 1199, 274012, 124600, 269678, 3~
## $ Series_Complete_Moderna                <dbl> 16097, 1116834, 746560, 1310927~
## $ Series_Complete_Pfizer                 <dbl> 11, 1649722, 822125, 1985705, 2~
## $ Series_Complete_Unk_Manuf              <dbl> 0, 293, 219, 2558, 53, 18, 137,~
## $ Series_Complete_Janssen_12Plus         <dbl> 1198, 273993, 124594, 269649, 3~
## $ Series_Complete_Moderna_12Plus         <dbl> 16089, 1116822, 746549, 1310893~
## $ Series_Complete_Pfizer_12Plus          <dbl> 11, 1641723, 822104, 1985603, 2~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 0, 293, 219, 2558, 53, 18, 137,~
## $ Series_Complete_Janssen_18Plus         <dbl> 1195, 273518, 124535, 269534, 3~
## $ Series_Complete_Moderna_18Plus         <dbl> 16071, 1114783, 746285, 1310577~
## $ Series_Complete_Pfizer_18Plus          <dbl> 9, 1469720, 781095, 1767515, 23~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 0, 282, 219, 2485, 52, 18, 120,~
## $ Series_Complete_Janssen_65Plus         <dbl> 65, 46101, 32206, 50551, 42106,~
## $ Series_Complete_Moderna_65Plus         <dbl> 943, 338638, 312228, 402682, 65~
## $ Series_Complete_Pfizer_65Plus          <dbl> 0, 416927, 246854, 390774, 6574~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 0, 65, 138, 748, 35, 11, 54, 0,~
## $ Series_Complete_FedLTC                 <dbl> 0, 68296, 35927, 78415, 90579, ~
## $ Series_Complete_FedLTC_Residents       <dbl> 0, 29784, 19890, 41147, 47820, ~
## $ Series_Complete_FedLTC_Staff           <dbl> 0, 28507, 12335, 30545, 29596, ~
## $ Series_Complete_FedLTC_Unknown         <dbl> 0, 10005, 3702, 6723, 13163, 14~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before   8.31e+9    1.66e+8   3.51e+7 605510       32981    
## 2 after    8.27e+9    1.65e+8   3.49e+7 602741       28509    
## 3 pctchg   4.40e-3    3.97e-3   4.59e-3      0.00457     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 28,509
## Columns: 6
## $ date       <date> 2021-02-12, 2020-08-22, 2020-06-05, 2021-07-27, 2021-01-06~
## $ state      <chr> "UT", "AR", "HI", "AK", "TX", "TX", "GA", "MA", "OK", "AK",~
## $ tot_cases  <dbl> 359641, 56199, 661, 71521, 1867163, 1236648, 493, 662699, 2~
## $ tot_deaths <dbl> 1785, 674, 17, 377, 33124, 23357, 13, 17427, 102, 17, 1331,~
## $ new_cases  <dbl> 1060, 547, 8, 235, 24010, 18811, 115, 1598, 96, 29, 89, 870~
## $ new_deaths <dbl> 11, 11, 0, 0, 345, 190, 7, 8, 5, 0, 1, 15, 2, 1, 0, 0, 34, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 2.78e+7    2.19e+7 471723      27682     
## 2 after  2.77e+7    2.18e+7 459822      26679     
## 3 pctchg 5.58e-3    5.57e-3      0.0252     0.0362
## 
## 
## Processed for cdcHosp:
## Rows: 26,679
## Columns: 5
## $ date       <date> 2020-07-22, 2020-07-20, 2020-07-19, 2020-07-18, 2020-07-18~
## $ state      <chr> "IA", "IA", "ND", "IA", "ND", "TX", "OK", "CT", "ND", "NM",~
## $ inp        <dbl> 0, 1, 46, 10, 33, 12003, 678, 215, 16, 119, 51, 19, 250, 14~
## $ hosp_adult <dbl> 0, 1, NA, 10, NA, 7999, 566, 115, NA, NA, NA, NA, NA, NA, N~
## $ hosp_ped   <dbl> 0, 0, NA, 0, NA, 194, 9, 0, NA, NA, NA, NA, NA, NA, NA, NA,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 8.40e+10 3.47e+10 311274.    1.13e+10 575411.     3.38e+10  384223.   
## 2 after  4.00e+10 1.68e+10 263386.    5.47e+ 9 524476.     1.63e+10  329394.   
## 3 pctchg 5.24e- 1 5.16e- 1      0.154 5.16e- 1      0.0885 5.16e- 1       0.143
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 11,883
## Columns: 9
## $ date        <date> 2021-08-03, 2021-08-03, 2021-08-03, 2021-08-03, 2021-08-0~
## $ state       <chr> "MN", "AL", "MD", "NC", "SD", "MO", "ND", "NE", "WY", "AZ"~
## $ vxa         <dbl> 6102310, 3634744, 7237660, 9776317, 854287, 5503756, 66497~
## $ vxc         <dbl> 3040861, 1693504, 3568868, 4606310, 416490, 2549091, 30623~
## $ vxcpoppct   <dbl> 53.9, 34.5, 59.0, 43.9, 47.1, 41.5, 40.2, 49.7, 36.7, 45.4~
## $ vxcgte65    <dbl> 801731, 591426, 844755, 1352070, 131441, 792717, 89800, 26~
## $ vxcgte65pct <dbl> 87.1, 69.6, 88.1, 77.2, 86.5, 74.6, 74.9, 85.7, 73.6, 74.5~
## $ vxcgte18    <dbl> 2858303, 1652134, 3350111, 4390894, 400144, 2446269, 29565~
## $ vxcgte18pct <dbl> 65.9, 43.3, 71.1, 53.6, 59.9, 51.3, 50.8, 62.6, 46.2, 55.7~
## 
## Integrated per capita data file:
## Rows: 28,722
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_210804, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_210804.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The raw hospital data is explored for admissions with confirmed/suspected coronavirus:

cdcHospAdmit_210804 <- cdc_daily_210804$dfRaw$cdcHosp %>%
    select(state, date, ends_with("confirmed"), ends_with("suspected")) %>%
    filter(state %in% c(state.abb, "DC")) %>%
    arrange(date, state) %>%
    pivot_longer(-c(state, date)) %>%
    mutate(name=stringr::str_replace(name, pattern="previous_day_admission_", replacement=""), 
           name=stringr::str_replace(name, pattern="_covid", replacement="")
           ) %>%
    left_join(getStateData(keepVars=c("state", "pop")), by="state") %>%
    mutate(vpm=1000000*value/pop) %>%
    group_by(state, name) %>%
    mutate(vpm7=zoo::rollmean(vpm, k=7, fill=NA)) %>%
    ungroup()

cdcHospAdmit_210804 %>%
    filter(!is.na(vpm7), state %in% state.abb) %>%
    mutate(div=as.character(state.division)[match(state, state.abb)]) %>%
    group_by(div, date, name) %>%
    summarize(wt_vpm7=sum(pop*vpm7)/sum(pop), tot_pop=sum(pop), .groups="drop") %>%
    ggplot(aes(x=date, y=wt_vpm7)) + 
    geom_col(aes(fill=name), position="stack") + 
    facet_wrap(~div) + 
    scale_fill_discrete("Metric") + 
    labs(x=NULL, 
         y="Newly admitted for COVID per million (rolling 7-day)", 
         title="Hospital admissions for COVID", 
         subtitle="All metrics divided by total population (all ages) for states reporting"
         )

Hospital coverage data became robust about a year ago. The overwhelming majority of admissions are adult, split between confirmed and suspected cases. Next steps are to explore changes in admissions by age groups:

hospAge_210804 <- cdc_daily_210804$dfRaw$cdcHosp %>%
    select(state, 
           date, 
           grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
           grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
           ) %>% 
    pivot_longer(-c(state, date)) %>% 
    mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
           adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
           age=ifelse(adultPed=="ped", "0-17", stringr::str_replace_all(string=name, pattern=".*_", replacement="")), 
           age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
           div=as.character(state.division)[match(state, state.abb)]
           ) 
hospAge_210804
## # A tibble: 498,276 x 8
##    state date       name                     value confSusp adultPed age   div  
##    <chr> <date>     <chr>                    <dbl> <chr>    <chr>    <chr> <chr>
##  1 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    0-19  <NA> 
##  2 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    20-29 <NA> 
##  3 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    30-39 <NA> 
##  4 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    40-49 <NA> 
##  5 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    50-59 <NA> 
##  6 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    60-69 <NA> 
##  7 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    70-79 <NA> 
##  8 PR    2020-07-27 previous_day_admission_~    NA confirm~ adult    80+   <NA> 
##  9 PR    2020-07-27 previous_day_admission_~    NA suspect~ adult    0-19  <NA> 
## 10 PR    2020-07-27 previous_day_admission_~    NA suspect~ adult    20-29 <NA> 
## # ... with 498,266 more rows
# Plot for overall trends by age group
p1 <- hospAge_210804 %>% 
    filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
    mutate(ageBucket=age) %>% 
    group_by(date, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    arrange(date) %>%
    group_by(ageBucket) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-08-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Jul 2021)", 
         subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
         ) + 
    lims(y=c(0, NA))

# Line plots by age group
p1 + 
    geom_line(aes(group=ageBucket, color=ageBucket), size=1) + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 row(s) containing missing values (geom_path).

# Stacked bar plots by age group
p1 + 
    geom_col(aes(fill=ageBucket), position="stack") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Proportions by age group
p1 + 
    geom_col(aes(fill=ageBucket), position="fill") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Plot for overall trends by age group
hospAge_210804 %>% 
    filter(state %in% state.abb, !is.na(value)) %>% 
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-06-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    geom_line(aes(color=ageBucket, group=ageBucket)) + 
    scale_color_discrete("Age\nbucket") + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Jul 2021)"
         ) + 
    lims(y=c(0, NA)) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 18 row(s) containing missing values (geom_path).

Next steps are to explore alignment of the hospitalization and case/death curves. Michigan having had a distinct spring peak is used as an example:

allHosp_210804 <- hospAge_210804 %>%
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>%
    ungroup() %>%
    left_join(getStateData(keepVars=c("state", "pop"))) %>%
    mutate(vpm7=1000000*value7/pop)
## Joining, by = "state"
allHosp_210804
## # A tibble: 83,046 x 7
##    date       state ageBucket value value7     pop  vpm7
##    <date>     <chr> <chr>     <dbl>  <dbl>   <dbl> <dbl>
##  1 2020-01-01 AL    0-19         NA     NA 4903185    NA
##  2 2020-01-01 AL    20-59        NA     NA 4903185    NA
##  3 2020-01-01 AL    60+          NA     NA 4903185    NA
##  4 2020-01-01 HI    0-19         NA     NA 1415872    NA
##  5 2020-01-01 HI    20-59        NA     NA 1415872    NA
##  6 2020-01-01 HI    60+          NA     NA 1415872    NA
##  7 2020-01-01 IN    0-19         NA     NA 6732219    NA
##  8 2020-01-01 IN    20-59        NA     NA 6732219    NA
##  9 2020-01-01 IN    60+          NA     NA 6732219    NA
## 10 2020-01-01 LA    0-19         NA     NA 4648794    NA
## # ... with 83,036 more rows
allCaseDeath_210804 <- cdc_daily_210804$dfPerCapita %>%
    select(state, date, new_cases, new_deaths, vxa, vxc, cpm7, dpm7, vxapm7, vxcpm7) %>%
    pivot_longer(-c(state, date))
allCaseDeath_210804
## # A tibble: 229,776 x 4
##    state date       name       value
##    <chr> <date>     <chr>      <dbl>
##  1 AL    2020-01-01 new_cases     NA
##  2 AL    2020-01-01 new_deaths    NA
##  3 AL    2020-01-01 vxa           NA
##  4 AL    2020-01-01 vxc           NA
##  5 AL    2020-01-01 cpm7          NA
##  6 AL    2020-01-01 dpm7          NA
##  7 AL    2020-01-01 vxapm7        NA
##  8 AL    2020-01-01 vxcpm7        NA
##  9 HI    2020-01-01 new_cases     NA
## 10 HI    2020-01-01 new_deaths    NA
## # ... with 229,766 more rows
allPivot_210804 <- allHosp_210804 %>%
    select(state, date, name=ageBucket, value=vpm7) %>%
    bind_rows(allCaseDeath_210804) %>%
    checkUniqueRows(uniqueBy=c("state", "date", "name"))
## 
## *** File has been checked for uniqueness by: state date name
allPivot_210804
## # A tibble: 312,822 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 312,812 more rows
# Plot Michigan data
typeMapper <- c("cases"="1. Cases per million per day (rolling 7 mean)", 
                "deaths"="2. Deaths per million per day (rolling 7 mean)", 
                "hosp"="3. Admitted to hospital per million per day (rolling 7 mean)", 
                "vax"="4. Vaccinated per capita (administered, completed)"
                )
allPivot_210804 %>%
    filter(state=="MI", !is.na(value)) %>%
    mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                              name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                              name=="cpm7" ~ "cases", 
                              name=="dpm7" ~ "deaths", 
                              TRUE ~ "notuse"
                              )
           ) %>%
    filter(plotType != "notuse") %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(data=~filter(., plotType=="cases"), color="blue", size=1) +
    geom_line(data=~filter(., plotType=="deaths"), color="red", size=1) +
    geom_line(data=~filter(., plotType=="vax"), aes(color=name, group=name, y=value/1000000)) +
    geom_col(data=~filter(., plotType=="hosp"), aes(fill=name), position="stack") + 
    scale_color_discrete("Vaccine\nMetric") + 
    scale_fill_discrete("Hospitalized\nby Age") +
    facet_wrap(~typeMapper[plotType], scales="free_y") + 
    labs(x=NULL, y=NULL) +
    lims(y=c(0, NA))

hospCase <- 10
allPivot_210804 %>%
    filter(state=="MI", !is.na(value)) %>%
    mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                              name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                              name=="cpm7" ~ "cases", 
                              name=="dpm7" ~ "deaths", 
                              TRUE ~ "notuse"
                              )
           ) %>%
    filter(plotType %in% c("cases", "hosp")) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospCase*value), position="stack") + 
    geom_line(data=~filter(., plotType=="cases"), color="black", size=1) +
    scale_fill_discrete("Hospital Admssions by Age") + 
    scale_y_continuous("Cases per million (rolling 7 mean per day)", 
                       sec.axis = sec_axis(~ . / hospCase, 
                                           name = "Hospital admissions per million (rolling 7 mean per day"
                                           )
                       ) +
    labs(x=NULL, 
         title="Alignment of Michigan cases and hospitalizations data", 
         subtitle=paste0("Ratio of ", 
                         hospCase, 
                         ":1 applied (cases are black line, hospital admissions are stacked bar)"
                         )
         ) + 
    theme(legend.position="bottom")

hospDeath <- 0.2
allPivot_210804 %>%
    filter(state=="MI", !is.na(value)) %>%
    mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                              name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                              name=="cpm7" ~ "cases", 
                              name=="dpm7" ~ "deaths", 
                              TRUE ~ "notuse"
                              )
           ) %>%
    filter(plotType %in% c("deaths", "hosp")) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospDeath*value), position="stack") + 
    geom_line(data=~filter(., plotType=="deaths"), color="black", size=1) +
    scale_fill_discrete("Hospital Admssions by Age") + 
    scale_y_continuous("Deaths per million (rolling 7 mean per day)", 
                       sec.axis = sec_axis(~ . / hospDeath, 
                                           name = "Hospital admissions per million (rolling 7 mean per day"
                                           )
                       ) +
    labs(x=NULL, 
         title="Alignment of Michigan deaths and hospitalizations data", 
         subtitle=paste0("Ratio of ", 
                         hospDeath, 
                         ":1 applied (deaths are black line, hospital admissions are stacked bar)"
                         )
         ) + 
    theme(legend.position="bottom")

At a glance, the Michigan data appear reasonably well aligned. Hospital admissions run at ~10% of confirmed cases with a small delay. Deaths run at ~20% of hospital admissions in the mid-winter wave and ~10% of admissions in the spring wave. These are consistent with estimates of ~1.5% CFR and ~5 cases per diagnosed cases (fatality rate ~0.3%).

Next steps are to convert this process to functional form, automate selection of scaling parameters, and explore other states of interest:

# Function to create case-hospital-death file
makeCaseHospDeath <- function(dfHosp, dfCaseDeath) {

    # FUNCTION ARGUMENTS:
    # dfHosp: the tibble or data.frame containing the hospital data by date-state
    # dfCaseDeath: the tibble or data.frame containing the case and death data by date-state
    
    allHosp <- dfHosp %>%
        mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
        group_by(date, state, ageBucket) %>% 
        summarize(value=sum(value), .groups="drop") %>% 
        group_by(ageBucket, state) %>% 
        mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>%
        ungroup() %>%
        left_join(getStateData(keepVars=c("state", "pop"))) %>%
        mutate(vpm7=1000000*value7/pop)

    allCaseDeath <- dfCaseDeath %>%
        select(state, date, new_cases, new_deaths, vxa, vxc, cpm7, dpm7, vxapm7, vxcpm7) %>%
        pivot_longer(-c(state, date))

    allPivot <- allHosp %>%
        select(state, date, name=ageBucket, value=vpm7) %>%
        bind_rows(allCaseDeath) %>%
        checkUniqueRows(uniqueBy=c("state", "date", "name"))
    
    allPivot
    
}

alignCaseHospDeath <- function(dfPivot=NULL, 
                               dfHosp=NULL, 
                               dfCaseDeath=NULL, 
                               typeMapper=c("cases"="1. Cases per million per day (rolling 7 mean)", 
                                            "deaths"="2. Deaths per million per day (rolling 7 mean)", 
                                            "hosp"="3. Admitted to hospital per million per day (rolling 7 mean)", 
                                            "vax"="4. Vaccinated per capita (administered, completed)"
                                            ), 
                               keyState="MI", 
                               hospCaseScalar=10, 
                               hospDeathScalar=0.2, 
                               returnPlots=FALSE
                               ) 
    {
    
    # FUNCTION ARGUMENTS:
    # dfPivot: the tibble or data.frame containing integrated case-hospital-death data 
    #          (if NULL, build from dfHosp and dfCaseDeath)
    # dfHosp: the tibble or data.frame containing the hospital data by date-state
    # dfCaseDeath: the tibble or data.frame containing the case and death data by date-state
    # typeMapper: mapping file for labelling facets
    # keyState: the state to explore
    # hospCaseScalar: the scalar to be applied for placing cases and hospitalizations on the same plot
    # hospDeathScalar: the scalar to be applied for placing hospitalizations and deaths on the same plot
    
    # Create the pivoted data if it was not passed
    if (is.null(dfPivot)) {
        if (is.null(dfHosp) | is.null(dfCaseDeath)) stop("\nMust pass dfPivot OR both of dfHosp and dfCaseDeath\n")
        dfPivot <- makeCaseHospDeath(dfHosp=dfHosp, dfCaseDeath=dfCaseDeath)
    }

    # Create the plotting data
    plotData <- dfPivot %>%
        filter(state==keyState, !is.na(value)) %>%
        mutate(plotType=case_when(name %in% c("0-19", "20-59", "60+") ~ "hosp", 
                                  name %in% c("vxapm7", "vxcpm7") ~ "vax", 
                                  name=="cpm7" ~ "cases", 
                                  name=="dpm7" ~ "deaths", 
                                  TRUE ~ "notuse"
                                  )
               )
    
    # Create overall plot
    p1 <- plotData %>%
        filter(plotType != "notuse") %>%
        ggplot(aes(x=date, y=value)) + 
        geom_line(data=~filter(., plotType=="cases"), color="blue", size=1) +
        geom_line(data=~filter(., plotType=="deaths"), color="red", size=1) +
        geom_line(data=~filter(., plotType=="vax"), aes(color=name, group=name, y=value/1000000)) +
        geom_col(data=~filter(., plotType=="hosp"), aes(fill=name), position="stack") + 
        scale_color_discrete("Vaccine\nMetric") + 
        scale_fill_discrete("Hospitalized\nby Age") +
        facet_wrap(~typeMapper[plotType], scales="free_y") + 
        labs(x=NULL, y=NULL, title=paste0("Key coronavirus metrics for state: ", keyState)) +
        lims(y=c(0, NA))
    print(p1)

    p2 <- plotData %>%
        filter(plotType %in% c("cases", "hosp")) %>%
        ggplot(aes(x=date, y=value)) + 
        geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospCaseScalar*value), position="stack") + 
        geom_line(data=~filter(., plotType=="cases"), color="black", size=1) +
        scale_fill_discrete("Hospital Admssions by Age") + 
        scale_y_continuous("Cases per million (rolling 7 mean per day)", 
                           sec.axis = sec_axis(~ . / hospCaseScalar, 
                                               name = "Hospital admissions per million (rolling 7 mean per day"
                                               )
                           ) +
        labs(x=NULL, 
             title=paste0("Alignment of ", keyState, " cases and hospitalizations data"), 
             subtitle=paste0("Ratio of ", 
                             hospCaseScalar, 
                             ":1 applied (cases are black line, hospital admissions are stacked bar)"
                             )
             ) + 
        theme(legend.position="bottom")
    print(p2)

    p3 <- plotData %>%
        filter(plotType %in% c("deaths", "hosp")) %>%
        ggplot(aes(x=date, y=value)) + 
        geom_col(data=~filter(., plotType=="hosp"), aes(fill=name, y=hospDeathScalar*value), position="stack") + 
        geom_line(data=~filter(., plotType=="deaths"), color="black", size=1) +
        scale_fill_discrete("Hospital Admssions by Age") + 
        scale_y_continuous("Deaths per million (rolling 7 mean per day)", 
                           sec.axis = sec_axis(~ . / hospDeathScalar, 
                                               name = "Hospital admissions per million (rolling 7 mean per day"
                                               )
                           ) +
        labs(x=NULL, 
             title=paste0("Alignment of ", keyState, " deaths and hospitalizations data"), 
             subtitle=paste0("Ratio of ", 
                             hospDeathScalar, 
                             ":1 applied (deaths are black line, hospital admissions are stacked bar)"
                             )
             ) + 
        theme(legend.position="bottom")
    print(p3)
    
    if(isTRUE(returnPlots)) list(p1=p1, p2=p2, p3=p3)
    
}

The function is tested for MI, FL, and TX:

dfPivot_210804 <- makeCaseHospDeath(dfHosp=hospAge_210804, dfCaseDeath=cdc_daily_210804$dfPerCapita)
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
dfPivot_210804
## # A tibble: 312,822 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 312,812 more rows
miAlign <- alignCaseHospDeath(dfPivot_210804, keyState="MI", returnPlots=TRUE)

flAlign <- alignCaseHospDeath(dfPivot_210804, keyState="FL", returnPlots=TRUE, hospDeathScalar=0.14)

txAlign <- alignCaseHospDeath(dfPivot_210804, keyState="TX", returnPlots=TRUE, hospDeathScalar=0.14)

# Key plots on a single page
gridExtra::grid.arrange(miAlign$p1, flAlign$p1, txAlign$p1, nrow=2)

gridExtra::grid.arrange(miAlign$p2, flAlign$p2, txAlign$p2, nrow=1)

gridExtra::grid.arrange(miAlign$p3, flAlign$p3, txAlign$p3, nrow=1)

Next, an implied CFR (deaths per case) rate is calculated for inclusion:

# Filter to single-state data
miData <- dfPivot_210804 %>%
    filter(state=="MI", name %in% c("cpm7", "dpm7"), !is.na(value))

# Plot core metrics
miData %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line(aes(group=name, color=name)) + 
    facet_wrap(~c("cpm7"="Cases per million", "dpm7"="Deaths per million")[name], scales="free_y") + 
    labs(x=NULL, y="Value per million (rolling 7-day mean)", title="Coronavirus burden in state: MI") + 
    theme(legend.position="none")

# Create correlation for assigned lag/lead and variables in a data frame
lagCorrCheck <- function(df, lagLead=0, varFix="dpm7", varMove="cpm7") {
    df %>%
        mutate(lagVar=if(lagLead >= 0) lag(get(varMove), lagLead) else lead(get(varMove), abs(lagLead))) %>%
        filter(!is.na(lagVar)) %>%
        summarize(correl=cor(lagVar, get(varFix))) %>%
        pull(correl)
}

miCorrDF <- miData %>%
    select(date, name, value) %>%
    pivot_wider(date)
miCorrDF
## # A tibble: 553 x 3
##    date        cpm7  dpm7
##    <date>     <dbl> <dbl>
##  1 2020-01-25     0     0
##  2 2020-01-26     0     0
##  3 2020-01-27     0     0
##  4 2020-01-28     0     0
##  5 2020-01-29     0     0
##  6 2020-01-30     0     0
##  7 2020-01-31     0     0
##  8 2020-02-01     0     0
##  9 2020-02-02     0     0
## 10 2020-02-03     0     0
## # ... with 543 more rows
# Assessing best lag/lead for full dataset
lagLeads=-10:40
miRhoFull <- tibble::tibble(lagLead=lagLeads, 
                            rho=sapply(lagLeads, FUN=function(x) lagCorrCheck(miCorrDF, lagLead=x))
                            )
bestFull <- miRhoFull %>% filter(rho==max(rho))
miRhoFull %>% 
    ggplot(aes(x=lagLead, y=rho)) + 
    geom_point() + 
    geom_hline(data=bestFull, aes(yintercept=rho), lty=2) +
    geom_vline(data=bestFull, aes(xintercept=lagLead), lty=2) +
    labs(x="Lag or lead of cases", 
         y="Correlation to deaths", 
         title="All Michigan case and death data", 
         subtitle=paste0("Best correlation ", 
                         round(bestFull$rho, 3), 
                         " obtained at lag/lead of: ", 
                         bestFull$lagLead
                         )
         )

# Assessing best lag/lead for August 2020 and beyond
lagLeads=-10:40
miRhoLate <- tibble::tibble(lagLead=lagLeads, 
                            rho=sapply(lagLeads, 
                                       FUN=function(x) lagCorrCheck(miCorrDF %>% filter(date >= "2020-08-01"), 
                                                                    lagLead=x
                                                                    )
                                       )
                            )
bestLate <- miRhoLate %>% filter(rho==max(rho))
miRhoLate %>% 
    ggplot(aes(x=lagLead, y=rho)) + 
    geom_point() + 
    geom_hline(data=bestLate, aes(yintercept=rho), lty=2) +
    geom_vline(data=bestLate, aes(xintercept=lagLead), lty=2) +
    labs(x="Lag or lead of cases", 
         y="Correlation to deaths", 
         title="Michigan case and death data (August 2020 to present)", 
         subtitle=paste0("Best correlation ", 
                         round(bestLate$rho, 3), 
                         " obtained at lag/lead of: ", 
                         bestLate$lagLead
                         )
         )

miCorrDF %>%
    mutate(lag20=lag(cpm7, 20)) %>%
    filter(!is.na(lag20), lag20 > 0) %>%
    ggplot(aes(x=date)) + 
    geom_line(aes(y=cpm7), color="navy") + 
    geom_line(aes(y=lag20), color="navy", lty=2) + 
    geom_line(aes(y=8000*pmin(0.1, dpm7/lag20)), color="red") + 
    scale_y_continuous("Cases per million (rolling 7 mean per day) - actual and 20-day lag", 
                       sec.axis = sec_axis(~ . / 8000, 
                                           name = "Implied CFR (capped at 10%)"
                                           )
                       ) +
    labs(x=NULL, title="Implied case fatality rate using 20-day lag in Michigan")

miCorrDF %>%
    mutate(lag20=lag(cpm7, 20)) %>%
    filter(!is.na(lag20)) %>%
    ggplot(aes(x=date)) + 
    geom_line(aes(y=cpm7), color="navy") + 
    geom_line(aes(y=lag20), color="navy", lty=2) + 
    geom_line(aes(y=50*dpm7), color="red") + 
    labs(x=NULL, 
         y="Per million (7-day rolling mean)\nCases, Lag-20 cases, and 50*Deaths", 
         title="Burden metrics for Michigan"
         )

Michigan appears to fairly consistently have a lag of 2-3 weeks between cases and deaths. The CFR during spikes has consistently declined from over 10% to around 2% to around 1%. The estimated CFR outside of spikes appears noisy. Next steps are to convert to functional form and run for other states:

# Create correlation for assigned lag/lead and variables in a data frame
lagCorrCheck <- function(df, lagLead=0, varFix="dpm7", varMove="cpm7") {
    df %>%
        mutate(lagVar=if(lagLead >= 0) lag(get(varMove), lagLead) else lead(get(varMove), abs(lagLead))) %>%
        filter(!is.na(lagVar)) %>%
        summarize(correl=cor(lagVar, get(varFix))) %>%
        pull(correl)
}


findCorrAlign <- function(df, 
                          keyState, 
                          varFix="dpm7", 
                          varMove="cpm7", 
                          lagLeads=-10:40,
                          minDate=NULL, 
                          maxDate=NULL,
                          varMapper=c("cpm7"="Cases per million", "dpm7"="Deaths per million"), 
                          yLab="Value per million (rolling 7-day mean)", 
                          printPlots=TRUE, 
                          returnPlots=FALSE,
                          returnData=FALSE
                          ) {
    
    # FUNCTION ARGUMENTS
    # df: pivoted data frame with state-date-name-value
    # keyState: state to include
    # varFix: metric to be held constant
    # varMove: metric to be lagged/led
    # lagLeads: lags and leads for the variable that moves
    # minDate: minimum date for lag/lead (NULL means data-driven)
    # maxDate: maximum date for lag/lead (NULL means data-driven)
    # varMapper: mapping file for varFix and varMove to descriptive labels
    # yLab: label for the y-axis in the first plot
    # printPlots: boolean, should the plots be printed?
    # returnPlots: boolean, should the plots be returned?
    # returnData: boolean, should the data frames be returned as a list?
    
    # Set minDate and maxDate to the actual minmax if passed as NULL 
    if (is.null(minDate)) minDate <- df %>% summarize(date=min(date)) %>% pull(date)
    if (is.null(maxDate)) maxDate <- df %>% summarize(date=max(date)) %>% pull(date)
    
    # Filter to relevant data
    df <- df %>%
        filter(state %in% all_of(keyState), name %in% all_of(c(varFix, varMove)), !is.na(value))

    # Plot core metrics for requested states
    p1 <- df %>%
        ggplot(aes(x=date, y=value)) + 
        geom_line(aes(group=name, color=name)) + 
        facet_wrap(~varMapper[name], scales="free_y") + 
        labs(x=NULL, y=yLab, title=paste0("Metrics by state for: ", paste0(keyState, collapse=", "))) + 
        theme(legend.position="none")
    if(isTRUE(printPlots)) print(p1)

    # Create dataset for correlations
    dfCorr <- df %>%
        select(date, name, value) %>%
        pivot_wider(date)

    # Find correlation by lag/lead for dataset
    dfRho <- tibble::tibble(lagLead=lagLeads, 
                            rho=sapply(lagLeads, 
                                       FUN=function(x) {
                                           lagCorrCheck(dfCorr %>% filter(date >= minDate, date <= maxDate), 
                                                        lagLead=x
                                                        )
                                           }
                                       )
                            )
    
    # Find best correlation and lag/lead
    bestRho <- dfRho %>% 
        filter(rho==max(rho))

    # Plot correlations by lag/lead
    p2 <- dfRho %>% 
        ggplot(aes(x=lagLead, y=rho)) + 
        geom_point() + 
        geom_hline(data=bestRho, aes(yintercept=rho), lty=2) +
        geom_vline(data=bestRho, aes(xintercept=lagLead), lty=2) +
        labs(x=paste0("Lag or lead of ", varMapper[varMove]), 
             y=paste0("Correlation to ", varMapper[varFix]), 
             title=paste0("Correlations by lag/lead for state: ", keyState), 
             subtitle=paste0("Best correlation ", 
                             round(bestRho$rho, 3), 
                             " obtained at lag/lead of: ", 
                             bestRho$lagLead
                             )
             )
    if(isTRUE(printPlots)) print(p2)

    if (isTRUE(returnData) | isTRUE(returnPlots)) {
        list(dfRho=if(isTRUE(returnData)) dfRho else NULL, 
             bestRho=if(isTRUE(returnData)) bestRho else NULL, 
             dfCorr=if(isTRUE(returnData)) dfCorr else NULL, 
             p1=if(isTRUE(returnPlots)) p1 else NULL, 
             p2=if(isTRUE(returnPlots)) p2 else NULL
             )
    }
    
}

findCorrAlign(dfPivot_210804, keyState="MI")

findCorrAlign(dfPivot_210804, keyState="MI", minDate="2020-08-01", returnData=TRUE)

## $dfRho
## # A tibble: 51 x 2
##    lagLead   rho
##      <int> <dbl>
##  1     -10 0.320
##  2      -9 0.348
##  3      -8 0.376
##  4      -7 0.404
##  5      -6 0.432
##  6      -5 0.460
##  7      -4 0.488
##  8      -3 0.515
##  9      -2 0.543
## 10      -1 0.570
## # ... with 41 more rows
## 
## $bestRho
## # A tibble: 1 x 2
##   lagLead   rho
##     <int> <dbl>
## 1      20 0.880
## 
## $dfCorr
## # A tibble: 553 x 3
##    date        cpm7  dpm7
##    <date>     <dbl> <dbl>
##  1 2020-01-25     0     0
##  2 2020-01-26     0     0
##  3 2020-01-27     0     0
##  4 2020-01-28     0     0
##  5 2020-01-29     0     0
##  6 2020-01-30     0     0
##  7 2020-01-31     0     0
##  8 2020-02-01     0     0
##  9 2020-02-02     0     0
## 10 2020-02-03     0     0
## # ... with 543 more rows
## 
## $p1
## NULL
## 
## $p2
## NULL
findCorrAlign(dfPivot_210804, keyState="FL")

findCorrAlign(dfPivot_210804, keyState="TX", minDate="2020-10-01")

Next steps are to create functional form for calculating IFR and aligning plots:

plotCFRLag <- function(lst, 
                       lagUse=NULL, 
                       scaleUse=NULL, 
                       cfrCap=0.06, 
                       multDeath=50,
                       mainTitle="Coronavirus data for selected geography: ", 
                       printPlots=TRUE, 
                       returnPlots=FALSE
                       ) {
    
    # FUNCTION ARGUMENTS:
    # lst: data frame with date-cpm7-dpm7 OR list with both dfCorr and bestRho
    # lagUse: the lag to use (if NULL, use the value in bestRho$lagLead)
    # scaleUse: scalar for secondary y-axis (NULL means calculate from data)
    # cfrCap: the cap for all values of CFR
    # multDeath: multiplier for death data in plot 2
    # mainTitle: main title for plots
    # printPlots: boolean, should the plots be printed?
    # returnPlots: boolean, should the plots be returned?
    
    # Create dfCorr and lagUse
    if ("list" %in% class(lst)) {
        dfCorr <- lst[["dfCorr"]]
        if (is.null(lagUse)) lagUse <- lst[["bestRho"]]$lagLead
    } else {
        dfCorr <- lst
    }
    
    # Check that dfCorr is a data frame with date-cpm7-dpm7 and lagUse is not NULL
    if (!("data.frame" %in% class(dfCorr))) stop("\nMust have a data frame for lst/dfCorr\n")
    if (!(all(c("date", "cpm7", "dpm7") %in% names(dfCorr)))) stop("\ndfCorr must have date-cpm7-dpm7\n")
    if (is.null(lagUse)) stop("\nMust have a value for lagUse\n")
    
    # Create scaleUse if not passed
    if (is.null(scaleUse)) scaleUse <- 500*ceiling(max(dfCorr$cpm7)/cfrCap/500)
    
    # Create plot of CFR by date, showing lagged cases
    basePlot <- dfCorr %>%
        mutate(lagData=if(lagUse >= 0) lag(cpm7, lagUse) else lead(cpm7, -lagUse)) %>%
        filter(!is.na(lagData), lagData > 0) %>%
        ggplot(aes(x=date)) + 
        geom_line(aes(y=cpm7), color="navy") + 
        geom_line(aes(y=lagData), color="navy", lty=2)
    p1 <- basePlot + 
        geom_line(aes(y=scaleUse*pmin(cfrCap, dpm7/lagData)), color="red") + 
        scale_y_continuous(paste0("Cases per million\n(rolling 7-day mean)"), 
                           sec.axis = sec_axis(~ . / scaleUse, 
                                               name = paste0("Implied CFR (capped at ", 
                                                             round(100*cfrCap, 1), 
                                                             "%)"
                                                             )
                                               )
                           ) +
        labs(x=NULL, 
             title=mainTitle, 
             subtitle=paste0("Red line (right axis) is implied fatality rate\n", 
                             "Blue line is cases with and without ", 
                             abs(lagUse), 
                             "-day ", 
                             if(lagUse > 0) "lag" else "lead"
                             )
             )
    if (isTRUE(printPlots)) print(p1)
    
    # Apply a CFR to the data and show alignment
    p2 <- basePlot +
        geom_line(aes(y=multDeath*dpm7), color="red") + 
        labs(x=NULL, 
             y="Per million (7-day rolling mean)", 
             title=mainTitle, 
             subtitle=paste0("Red line is ", 
                             multDeath, 
                             "*deaths\n", 
                             "Blue line is cases with and without ", 
                             abs(lagUse), 
                             "-day ", 
                             if(lagUse > 0) "lag" else "lead"
                             )
         )
    if (isTRUE(printPlots))print(p2)
    
    if (isTRUE(returnPlots)) list(p1=p1, p2=p2)
    
}

# Run for Michigan, Florida, California
findCorrAlign(dfPivot_210804, keyState="MI", minDate="2020-08-01", returnData=TRUE) %>%
    plotCFRLag(mainTitle=paste0(formals(plotCFRLag)$mainTitle, "MI"))

findCorrAlign(dfPivot_210804, keyState="FL", returnData=TRUE) %>%
    plotCFRLag(mainTitle=paste0(formals(plotCFRLag)$mainTitle, "FL"), multDeath=100)

findCorrAlign(dfPivot_210804, keyState="CA", returnData=TRUE) %>%
    plotCFRLag(mainTitle=paste0(formals(plotCFRLag)$mainTitle, "CA"), multDeath=70)

Functions have been updated so that plots can be returned and/or printed. A new function allows for creating all plots for state on a single page:

# Function to plot all states on the same page
onePageCFRPlot <- function(df, keyState, multDeath=100, cfrCap=0.06, ...) {
    
    # FUNCTION ARGUMENTS:
    # df: the data frame containing state-date-name-value
    # keyState: the key state to be analyzed
    # multDeath: multiplier for death in the death/lagged cases chart of plotCFRLag()
    # ...: other arguments to be passed to findCorrAlign()
    
    # Find the correlations data
    corrData <- findCorrAlign(df, 
                              keyState=keyState, 
                              yLab="Value per million\n(rolling 7-day mean)", 
                              printPlots=FALSE, 
                              returnPlots=TRUE, 
                              returnData=TRUE, 
                              ...
                              )
    
    # Find CFR
    cfrData <- plotCFRLag(corrData, 
                          cfrCap=cfrCap, 
                          multDeath=multDeath, 
                          mainTitle=paste0(formals(plotCFRLag)$mainTitle, keyState), 
                          printPlots=FALSE, 
                          returnPlots=TRUE
                          )
    
    # Create single-page summary
    gridExtra::grid.arrange(corrData$p1, corrData$p2, cfrData$p1, cfrData$p2, nrow=2)
    
}

# Run for Michigan, Florida, California, Texas, New York, South Dakota
onePageCFRPlot(dfPivot_210804, keyState="MI", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210804, keyState="FL", multDeath=100)

onePageCFRPlot(dfPivot_210804, keyState="CA", multDeath=70)

onePageCFRPlot(dfPivot_210804, keyState="TX", multDeath=70)

onePageCFRPlot(dfPivot_210804, keyState="NY", multDeath=10, cfrCap=0.1)

onePageCFRPlot(dfPivot_210804, keyState="SD", multDeath=70)

Summaries are created for vaccination status by age cohort and state:

cdc_daily_210815 <- readFromRDS("cdc_daily_210815")

# Example using hard coding and wide data
cdc_daily_210815$dfRaw$vax %>% 
    filter(date==max(date), state %in% c(state.abb, "DC")) %>% 
    select(state, contains("Administered_Dose1")) %>% 
    ggplot(aes(x=fct_reorder(state, Administered_Dose1_Recip_65PlusPop_Pct))) + 
    geom_col(aes(fill="65+", y=Administered_Dose1_Recip_65PlusPop_Pct)) + 
    geom_col(aes(y=Administered_Dose1_Recip_18PlusPop_Pct, fill="18+")) + 
    geom_col(aes(y=Administered_Dose1_Pop_Pct, fill="All")) + 
    geom_text(aes(y=Administered_Dose1_Recip_65PlusPop_Pct, 
                  label=paste0(Administered_Dose1_Recip_65PlusPop_Pct, "% (", state, ")")
                  ), 
              hjust=0, 
              size=3
              ) + 
    geom_text(aes(y=Administered_Dose1_Recip_18PlusPop_Pct+0.5, 
                  label=paste0(Administered_Dose1_Recip_18PlusPop_Pct, "%")
                  ), 
              hjust=0, 
              size=3
              ) + 
    coord_flip() + 
    labs(x=NULL, 
         y="% Fully Vaccinated", 
         title="First-dose vaccinated by age cohort and state (mid-Aug 2020)", 
         subtitle="Black: all population, Yellow: 18+, Blue: 65+"
         ) + 
    scale_fill_manual("Cohort", 
                      breaks=c("All", "18+", "65+"), 
                      values=c("65+"="lightblue", "18+"="yellow", "All"="black" )
                      ) + 
    geom_text(aes(y=Administered_Dose1_Pop_Pct+0.5, 
                  label=paste0(Administered_Dose1_Pop_Pct, "%")
                  ), 
              hjust=0, 
              size=3
              ) + 
    theme(legend.position="bottom")

# Function for reproducibility
tempStackPlot <- function(df, 
                          yVars, 
                          xVar="state", 
                          yLab="", 
                          plotTitle="", 
                          colorVector=c("lightblue", "grey", "orange", "black")
                          ) {

    # FUNCTION ARGUMENTS:
    # df: data frame or tibble
    # yVars: named vector with c("variable"="name")
    # xVar: the x variable
    # yLab: the y-axis label for the plot
    # plotTitle: the title for the plot
    # colorVector: colors to use for filled bars (sequentially, can have more, but not less, than length(yVars))
    
    colorVector <- colorVector[1:length(yVars)]
    names(colorVector) <- names(yVars)
    
    p1 <- df %>% 
        select(all_of(xVar), all_of(names(yVars))) %>%
        pivot_longer(-c(all_of(xVar))) %>%
        ggplot(aes(x=fct_reorder(get(xVar[1]), value, max))) + 
        coord_flip() + 
        labs(x=NULL, y=yLab, title=plotTitle) + 
        geom_col(aes(y=value, fill=name), position="identity") + 
        geom_text(aes(y=value+0.5, 
                      label=paste0(value, "%", ifelse(name==names(yVars)[1], paste0(" (", state, ")"), ""))
                      ), 
                  hjust=0, 
                  size=3
                  ) + 
        scale_fill_manual("Cohort", 
                          breaks=rev(names(yVars)), 
                          labels=rev(unname(yVars)),
                          values=colorVector
                          ) +
        theme(legend.position="bottom")

    p1
    
}

# Run for fully vaccinated
tempStackPlot(cdc_daily_210815$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("vxcgte65pct"="65+", 
                      "vxcgte18pct"="18+", 
                      "vxcpoppct"="All"
                      ), 
              yLab="% Fully vaccinated", 
              plotTitle="Fully vaccinated by age cohort and state (mid-Aug 2020)"
              )

# Run for first dose
tempStackPlot(cdc_daily_210815$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("Administered_Dose1_Recip_65PlusPop_Pct"="65+", 
                      "Administered_Dose1_Recip_18PlusPop_Pct"="18+", 
                      "Administered_Dose1_Pop_Pct"="All"
                      ), 
              yLab="% Receiving First Dose", 
              plotTitle="First-dose vaccinated by age cohort and state (mid-Aug 2020)"
              )

The plotting is extended to show the evolution of vaccination over time:

# Create data
cdcVaxGrowth <- cdc_daily_210815$dfRaw$vax %>% 
    filter(date %in% c(as.Date(max(date)-lubridate::dmonths(c(0, 2, 4)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for fuly vaccinated
p1 <- cdcVaxGrowth %>%
    select(state, date, vxcpoppct) %>%
    pivot_wider(state, names_from="date", values_from="vxcpoppct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% Fully Vaccinated (all population)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

p2 <- cdcVaxGrowth %>%
    select(state, date, vxcgte65pct) %>%
    pivot_wider(state, names_from="date", values_from="vxcgte65pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% Fully Vaccinated (65+)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

# Run for first dose
p1 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Pop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Pop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (all population)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

p2 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Recip_65PlusPop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Recip_65PlusPop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (65+)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

Similar plots are created for the evolution of cases per thousand and deaths per milion:

# Updated function for reproducibility
tempStackPlot <- function(df, 
                          yVars, 
                          xVar="state", 
                          yLab=NULL, 
                          plotTitle=NULL, 
                          colorVector=c("lightblue", "grey", "orange", "black"), 
                          addSuffix="%", 
                          scaleName="Cohort", 
                          textBuffer=0.5, 
                          makeDotPlot=FALSE, 
                          yLims=NULL
                          ) {

    # FUNCTION ARGUMENTS:
    # df: data frame or tibble
    # yVars: named vector with c("variable"="name"), in the desired order from right-most to left-most
    # xVar: the x variable
    # yLab: the y-axis label for the plot
    # plotTitle: the title for the plot
    # colorVector: colors to use for filled bars (sequentially, can have more, but not less, than length(yVars))
    # addSuffix: value to be appended to all values in plots (e.g., 96 would show as 96% in the text label)
    # scaleName: the name to use for the legend
    # textBuffer: distance from bar to text
    # makeDotPlot: boolean, should a dot-plot be made rather than stacked bars?
    # yLims: the limits for the y-axis passed as a length-2 vector such as c(0, 100) or c(0, NA)
    
    colorVector <- colorVector[1:length(yVars)]
    names(colorVector) <- names(yVars)
    
    # Function for the legend
    fnLegendKey <- if(isTRUE(makeDotPlot)) scale_color_manual else scale_fill_manual
    
    p1 <- df %>% 
        select(all_of(xVar), all_of(names(yVars))) %>%
        pivot_longer(-c(all_of(xVar))) %>%
        ggplot(aes(x=fct_reorder(get(xVar[1]), value, max))) + 
        coord_flip() + 
        labs(x=NULL, y=yLab, title=plotTitle) +
        (if(isTRUE(makeDotPlot)) geom_point(aes(y=value, color=name)) 
         else geom_col(aes(y=value, fill=name), position="identity")
         ) +
        geom_text(aes(y=value+textBuffer, 
                      label=paste0(value, 
                                   addSuffix, 
                                   ifelse(name==names(yVars)[1], paste0(" (", get(xVar[1]), ")"), "")
                                   )
                      ), 
                  hjust=0, 
                  size=3
                  ) + 
        fnLegendKey(scaleName, 
                    breaks=rev(names(yVars)), 
                    labels=rev(unname(yVars)),
                    values=colorVector
                    ) +
        theme(legend.position="bottom")
    
    # Add the y-limits if appropriate
    if (!is.null(yLims)) p1 <- p1 + lims(y=yLims)
    
    p1
    
}


# Create data
cdcBurdenGrowth <- cdc_daily_210815$dfPerCapita %>% 
    filter(date %in% c(as.Date(max(date)-2-lubridate::dmonths(c(0, 6, 12)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for cases
p1 <- cdcBurdenGrowth %>%
    select(state, date, tcpm) %>% 
    mutate(tcpm=round(tcpm/1000)) %>%
    pivot_wider(state, names_from="date", values_from="tcpm") %>%
    tempStackPlot(yVars=c("2021-08-13"="2021-08-13", 
                          "2021-02-11"="2021-02-11", 
                          "2020-08-12"="2020-08-12"
                          ), 
                  yLab="Cumulative cases per thousand", 
                  plotTitle="Evolution of cumulative cases per thousand by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

# Run for deaths
p2 <- cdcBurdenGrowth %>%
    select(state, date, tdpm) %>% 
    mutate(tdpm=round(tdpm)) %>%
    pivot_wider(state, names_from="date", values_from="tdpm") %>%
    tempStackPlot(yVars=c("2021-08-13"="2021-08-13", 
                          "2021-02-11"="2021-02-11", 
                          "2020-08-12"="2020-08-12"
                          ), 
                  yLab="Cumulative deaths per million", 
                  plotTitle="Evolution of cumulative deaths per million by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

The latest data as of August 31 are downloaded and processed, with caching to avoid multiple file downloads:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_210902.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_210902.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_210902.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210804")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210804")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210804")$dfRaw$vax
                    )

cdc_daily_210902 <- readRunCDCDaily(thruLabel="Sep 1, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_210902.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths        0      143      143 2.00000000
## 2   2020-02-03 tot_deaths      178      143       35 0.21806854
## 3   2020-02-04 tot_deaths      178      143       35 0.21806854
## 4   2020-02-05 tot_deaths      178      143       35 0.21806854
## 5   2020-02-06 tot_deaths      178      143       35 0.21806854
## 6   2020-02-07 tot_deaths      178      143       35 0.21806854
## 7   2020-02-08 tot_deaths      179      144       35 0.21671827
## 8   2020-02-09 tot_deaths      179      144       35 0.21671827
## 9   2020-02-10 tot_deaths      179      144       35 0.21671827
## 10  2020-02-11 tot_deaths      179      144       35 0.21671827
## 11  2020-02-12 tot_deaths      179      144       35 0.21671827
## 12  2020-02-13 tot_deaths      179      144       35 0.21671827
## 13  2020-02-14 tot_deaths      179      144       35 0.21671827
## 14  2020-02-15 tot_deaths      179      144       35 0.21671827
## 15  2020-02-16 tot_deaths      179      144       35 0.21671827
## 16  2020-02-17 tot_deaths      179      144       35 0.21671827
## 17  2020-02-18 tot_deaths      179      144       35 0.21671827
## 18  2020-02-19 tot_deaths      180      145       35 0.21538462
## 19  2020-02-20 tot_deaths      180      145       35 0.21538462
## 20  2020-02-21 tot_deaths      180      145       35 0.21538462
## 21  2020-02-22 tot_deaths      180      145       35 0.21538462
## 22  2020-02-23 tot_deaths      180      145       35 0.21538462
## 23  2020-02-24 tot_deaths      180      145       35 0.21538462
## 24  2020-02-25 tot_deaths      180      145       35 0.21538462
## 25  2020-02-26 tot_deaths      180      145       35 0.21538462
## 26  2020-02-27 tot_deaths      181      146       35 0.21406728
## 27  2020-02-28 tot_deaths      181      146       35 0.21406728
## 28  2020-02-29 tot_deaths      182      147       35 0.21276596
## 29  2020-03-01 tot_deaths      182      147       35 0.21276596
## 30  2020-03-02 tot_deaths      188      153       35 0.20527859
## 31  2020-03-06 tot_deaths      200      163       37 0.20385675
## 32  2020-03-05 tot_deaths      196      160       36 0.20224719
## 33  2020-03-03 tot_deaths      191      156       35 0.20172911
## 34  2020-03-04 tot_deaths      193      158       35 0.19943020
## 35  2020-03-07 tot_deaths      205      168       37 0.19839142
## 36  2020-03-08 tot_deaths      210      173       37 0.19321149
## 37  2020-03-10 tot_deaths      220      184       36 0.17821782
## 38  2020-03-09 tot_deaths      214      179       35 0.17811705
## 39  2020-03-11 tot_deaths      234      198       36 0.16666667
## 40  2020-03-12 tot_deaths      241      205       36 0.16143498
## 41  2020-03-13 tot_deaths      252      216       36 0.15384615
## 42  2020-03-14 tot_deaths      266      229       37 0.14949495
## 43  2020-03-15 tot_deaths      286      249       37 0.13831776
## 44  2020-03-16 tot_deaths      307      271       36 0.12456747
## 45  2020-03-17 tot_deaths      339      301       38 0.11875000
## 46  2020-03-18 tot_deaths      410      373       37 0.09450830
## 47  2020-03-20 tot_deaths      577      530       47 0.08491418
## 48  2020-03-19 tot_deaths      475      437       38 0.08333333
## 49  2020-03-21 tot_deaths      692      644       48 0.07185629
## 50  2020-03-22 tot_deaths      827      775       52 0.06491885
## 51  2020-03-25 tot_deaths     1544     1459       85 0.05661006
## 52  2020-03-24 tot_deaths     1232     1165       67 0.05590321
## 53  2020-03-23 tot_deaths      998      946       52 0.05349794
## 54  2020-03-26 tot_deaths     1897     1804       93 0.05025669
## 55  2020-02-02  tot_cases       56      510      454 1.60424028
## 56  2021-07-25 new_deaths      261      136      125 0.62972292
## 57  2021-07-24 new_deaths      287      162      125 0.55679287
## 58  2021-07-18 new_deaths      166       96       70 0.53435115
## 59  2021-07-23 new_deaths      388      226      162 0.52768730
## 60  2021-08-01 new_deaths      363      240      123 0.40796020
## 61  2021-07-26 new_deaths      368      245      123 0.40130506
## 62  2021-06-08 new_deaths      313      209      104 0.39846743
## 63  2021-06-07 new_deaths      339      500      161 0.38379023
## 64  2020-11-11 new_deaths     1516     1046      470 0.36690086
## 65  2021-07-31 new_deaths      397      274      123 0.36661699
## 66  2021-07-17 new_deaths      196      138       58 0.34730539
## 67  2021-07-19 new_deaths      256      185       71 0.32199546
## 68  2020-11-12 new_deaths     1366     1863      497 0.30783524
## 69  2020-11-10 new_deaths     1310     1761      451 0.29371540
## 70  2021-08-02 new_deaths      523      392      131 0.28633880
## 71  2021-07-05 new_deaths      141      106       35 0.28340081
## 72  2021-07-04 new_deaths      131      101       30 0.25862069
## 73  2021-06-17 new_deaths      268      334       66 0.21926910
## 74  2021-07-28 new_deaths      443      356       87 0.21777222
## 75  2021-07-29 new_deaths      460      370       90 0.21686747
## 76  2021-05-31 new_deaths      268      218       50 0.20576132
## 77  2020-09-30 new_deaths      537      660      123 0.20551378
## 78  2021-07-12 new_deaths      227      186       41 0.19854722
## 79  2021-06-13 new_deaths      167      200       33 0.17983651
## 80  2020-10-11 new_deaths      565      675      110 0.17741935
## 81  2021-06-21 new_deaths      265      315       50 0.17241379
## 82  2021-07-15 new_deaths      298      251       47 0.17122040
## 83  2020-07-13 new_deaths      869      732      137 0.17114304
## 84  2021-07-11 new_deaths      140      118       22 0.17054264
## 85  2021-07-10 new_deaths      153      129       24 0.17021277
## 86  2021-07-27 new_deaths      464      393       71 0.16569428
## 87  2020-10-08 new_deaths      681      803      122 0.16442049
## 88  2021-06-14 new_deaths      221      260       39 0.16216216
## 89  2021-07-20 new_deaths      316      269       47 0.16068376
## 90  2021-07-06 new_deaths      203      173       30 0.15957447
## 91  2021-06-01 new_deaths      334      391       57 0.15724138
## 92  2020-09-24 new_deaths      694      812      118 0.15670651
## 93  2020-07-26 new_deaths      937      802      135 0.15526164
## 94  2020-09-07 new_deaths      557      477       80 0.15473888
## 95  2021-07-22 new_deaths      331      386       55 0.15341702
## 96  2020-08-02 new_deaths      919      789      130 0.15222482
## 97  2020-09-23 new_deaths      812      944      132 0.15034169
## 98  2020-08-30 new_deaths      638      552       86 0.14453782
## 99  2021-04-11 new_deaths      428      371       57 0.14267835
## 100 2021-07-16 new_deaths      301      261       40 0.14234875
## 101 2020-09-10 new_deaths      789      908      119 0.14024750
## 102 2021-07-09 new_deaths      268      233       35 0.13972056
## 103 2020-07-12 new_deaths      865      753      112 0.13844252
## 104 2020-09-13 new_deaths      713      623       90 0.13473054
## 105 2021-06-19 new_deaths      206      180       26 0.13471503
## 106 2021-05-29 new_deaths      351      307       44 0.13373860
## 107 2020-10-15 new_deaths      693      792       99 0.13333333
## 108 2020-09-09 new_deaths      840      959      119 0.13229572
## 109 2020-09-06 new_deaths      661      580       81 0.13053989
## 110 2020-09-20 new_deaths      473      416       57 0.12823397
## 111 2020-08-09 new_deaths      856      756      100 0.12406948
## 112 2020-07-19 new_deaths      981      869      112 0.12108108
## 113 2021-03-26 new_deaths      844      951      107 0.11922006
## 114 2021-07-03 new_deaths      160      142       18 0.11920530
## 115 2021-07-07 new_deaths      239      269       30 0.11811024
## 116 2021-06-24 new_deaths      255      287       32 0.11808118
## 117 2020-08-17 new_deaths      834      742       92 0.11675127
## 118 2020-07-20 new_deaths     1028      915      113 0.11631498
## 119 2020-09-28 new_deaths      518      462       56 0.11428571
## 120 2020-08-04 new_deaths     1217     1087      130 0.11284722
## 121 2020-07-27 new_deaths     1115      997      118 0.11174242
## 122 2020-09-17 new_deaths      698      778       80 0.10840108
## 123 2021-06-04 new_deaths      522      469       53 0.10696266
## 124 2020-07-25 new_deaths     1153     1036      117 0.10689813
## 125 2021-06-12 new_deaths      298      268       30 0.10600707
## 126 2020-07-05 new_deaths      571      514       57 0.10506912
## 127 2020-07-06 new_deaths      716      645       71 0.10433505
## 128 2021-05-30 new_deaths      263      237       26 0.10400000
## 129 2020-09-11 new_deaths      797      884       87 0.10350982
## 130 2021-06-05 new_deaths      319      288       31 0.10214168
## 131 2020-07-09 new_deaths      883      798       85 0.10113028
## 132 2021-05-27 new_deaths      508      561       53 0.09915809
## 133 2020-09-21 new_deaths      657      596       61 0.09736632
## 134 2020-09-18 new_deaths      773      852       79 0.09723077
## 135 2020-07-04 new_deaths      572      519       53 0.09715857
## 136 2020-09-16 new_deaths      985     1085      100 0.09661836
## 137 2021-06-06 new_deaths      225      247       22 0.09322034
## 138 2020-08-06 new_deaths     1236     1126      110 0.09314141
## 139 2020-07-18 new_deaths     1001      912       89 0.09304757
## 140 2020-03-20 new_deaths      102       93        9 0.09230769
## 141 2020-10-09 new_deaths      745      816       71 0.09096733
## 142 2020-06-22 new_deaths      583      533       50 0.08960573
## 143 2021-07-01 new_deaths      216      236       20 0.08849558
## 144 2020-10-01 new_deaths      704      768       64 0.08695652
## 145 2021-06-20 new_deaths      193      177       16 0.08648649
## 146 2020-08-23 new_deaths      753      692       61 0.08442907
## 147 2021-06-30 new_deaths      247      227       20 0.08438819
## 148 2020-10-10 new_deaths      656      603       53 0.08419380
## 149 2020-09-15 new_deaths      793      862       69 0.08338369
## 150 2020-10-13 new_deaths      741      805       64 0.08279431
## 151 2021-07-02 new_deaths      265      244       21 0.08251473
## 152 2021-06-18 new_deaths      228      210       18 0.08219178
## 153 2020-08-24 new_deaths      779      718       61 0.08149633
## 154 2021-05-20 new_deaths      498      540       42 0.08092486
## 155 2021-05-25 new_deaths      491      532       41 0.08015640
## 156 2020-09-01 new_deaths      960     1040       80 0.08000000
## 157 2020-09-03 new_deaths      882      954       72 0.07843137
## 158 2021-06-15 new_deaths      311      336       25 0.07727975
## 159 2021-03-25 new_deaths      762      823       61 0.07697161
## 160 2020-09-27 new_deaths      489      453       36 0.07643312
## 161 2020-09-12 new_deaths      599      646       47 0.07550201
## 162 2020-08-31 new_deaths      688      638       50 0.07541478
## 163 2020-09-25 new_deaths      705      760       55 0.07508532
## 164 2020-06-14 new_deaths      491      456       35 0.07391763
## 165 2020-07-17 new_deaths     1097     1020       77 0.07274445
## 166 2020-08-18 new_deaths     1034     1112       78 0.07269338
## 167 2020-09-29 new_deaths      862      927       65 0.07266629
## 168 2020-07-24 new_deaths     1337     1244       93 0.07206509
## 169 2021-06-26 new_deaths      188      175       13 0.07162534
## 170 2020-10-07 new_deaths      791      849       58 0.07073171
## 171 2021-02-16 new_deaths     1579     1694      115 0.07027192
## 172 2021-06-28 new_deaths      207      193       14 0.07000000
## 173 2020-10-25 new_deaths      654      610       44 0.06962025
## 174 2021-04-16 new_deaths      755      809       54 0.06905371
## 175 2021-05-09 new_deaths      383      358       25 0.06747638
## 176 2021-03-14 new_deaths      635      594       41 0.06672091
## 177 2021-03-30 new_deaths      725      775       50 0.06666667
## 178 2021-04-05 new_deaths      404      378       26 0.06649616
## 179 2020-03-24 new_deaths      234      219       15 0.06622517
## 180 2020-07-15 new_deaths     1171     1096       75 0.06616674
## 181 2021-06-16 new_deaths      331      310       21 0.06552262
## 182 2020-09-14 new_deaths      538      504       34 0.06525912
## 183 2021-05-18 new_deaths      615      656       41 0.06451613
## 184 2020-07-21 new_deaths     1332     1251       81 0.06271777
## 185 2021-05-04 new_deaths      698      743       45 0.06245663
## 186 2021-05-21 new_deaths      590      628       38 0.06239737
## 187 2020-08-14 new_deaths     1011     1076       65 0.06229037
## 188 2020-08-25 new_deaths      975     1037       62 0.06163022
## 189 2020-12-25 new_deaths     2489     2341      148 0.06128364
## 190 2021-07-30 new_deaths      488      459       29 0.06124604
## 191 2020-10-21 new_deaths     1046     1112       66 0.06116775
## 192 2020-07-11 new_deaths      880      828       52 0.06088993
## 193 2021-04-26 new_deaths      496      527       31 0.06060606
## 194 2020-08-01 new_deaths     1144     1077       67 0.06033318
## 195 2021-06-02 new_deaths      472      501       29 0.05960946
## 196 2020-03-25 new_deaths      312      294       18 0.05940594
## 197 2021-05-26 new_deaths      497      527       30 0.05859375
## 198 2020-06-21 new_deaths      406      383       23 0.05830165
## 199 2021-01-01 new_deaths     3181     3001      180 0.05823358
## 200 2021-04-25 new_deaths      425      401       24 0.05811138
## 201 2020-08-22 new_deaths      898      848       50 0.05727377
## 202 2020-10-17 new_deaths      666      705       39 0.05689278
## 203 2021-06-27 new_deaths      147      139        8 0.05594406
## 204 2020-08-28 new_deaths      950      899       51 0.05516495
## 205 2021-04-06 new_deaths      726      767       41 0.05492297
## 206 2020-08-20 new_deaths      974      922       52 0.05485232
## 207 2020-10-02 new_deaths      772      815       43 0.05419030
## 208 2021-05-02 new_deaths      408      387       21 0.05283019
## 209 2021-04-08 new_deaths      741      781       40 0.05256242
## 210 2020-07-22 new_deaths     1204     1143       61 0.05198125
## 211 2020-06-29 new_deaths      537      510       27 0.05157593
## 212 2021-03-16 new_deaths      889      936       47 0.05150685
## 213 2021-02-19 new_deaths     2138     2251      113 0.05149237
## 214 2021-05-16 new_deaths      419      398       21 0.05140759
## 215 2021-06-10 new_deaths      381      401       20 0.05115090
## 216 2021-04-19 new_deaths      503      478       25 0.05096840
## 217 2020-06-27 new_deaths      585      556       29 0.05083260
## 218 2020-05-04 new_deaths     1341     1275       66 0.05045872
## 219 2021-07-21 new_deaths      387      407       20 0.05037783
## 220 2021-03-09 new_deaths     1067     1122       55 0.05025126
## 221 2020-11-07  new_cases   131351    95671    35680 0.31433077
## 222 2021-07-29  new_cases   100196    83462    16734 0.18223001
## 223 2020-08-31  new_cases    36964    31737     5227 0.15216664
## 224 2021-07-26  new_cases    58003    51051     6952 0.12749647
## 225 2021-07-28  new_cases    95770    84435    11335 0.12580117
## 226 2020-09-01  new_cases    39422    44538     5116 0.12186756
## 227 2021-07-27  new_cases    87274    77663     9611 0.11654147
## 228 2021-03-01  new_cases    51474    45900     5574 0.11448641
## 229 2021-06-06  new_cases    10806    12103     1297 0.11323061
## 230 2021-07-06  new_cases    16808    15036     1772 0.11129255
## 231 2021-06-28  new_cases    10809     9695     1114 0.10866172
## 232 2021-04-12  new_cases    60933    54867     6066 0.10476684
## 233 2021-01-02  new_cases   202831   223976    21145 0.09908460
## 234 2021-07-20  new_cases    53097    48234     4863 0.09598247
## 235 2020-07-05  new_cases    41454    45432     3978 0.09156826
## 236 2020-10-11  new_cases    43907    47898     3991 0.08694516
## 237 2020-12-26  new_cases   139718   151877    12159 0.08339649
## 238 2021-07-31  new_cases    93001    85965     7036 0.07862946
## 239 2021-04-18  new_cases    47829    51724     3895 0.07824978
## 240 2020-06-25  new_cases    52896    48970     3926 0.07708166
## 241 2020-10-10  new_cases    54532    50606     3926 0.07468280
## 242 2021-05-22  new_cases    21567    23239     1672 0.07463286
## 243 2020-05-28  new_cases    25872    24023     1849 0.07411564
## 244 2021-04-11  new_cases    49741    53464     3723 0.07214767
## 245 2021-07-12  new_cases    24378    22694     1684 0.07154997
## 246 2020-11-26  new_cases   154983   166180    11197 0.06972783
## 247 2020-07-11  new_cases    71048    66320     4728 0.06883699
## 248 2020-06-28  new_cases    42359    45369     3010 0.06862119
## 249 2020-07-13  new_cases    54767    58407     3640 0.06432573
## 250 2021-07-19  new_cases    37518    35205     2313 0.06361124
## 251 2021-02-28  new_cases    48809    51996     3187 0.06323099
## 252 2020-07-15  new_cases    74721    70325     4396 0.06061525
## 253 2021-06-05  new_cases    14629    15543      914 0.06058597
## 254 2020-10-04  new_cases    34481    36560     2079 0.05852958
## 255 2020-07-07  new_cases    61055    57638     3417 0.05757711
## 256 2020-08-09  new_cases    41301    43702     2401 0.05649212
## 257 2020-05-21  new_cases    26310    27823     1513 0.05589936
## 258 2021-06-25  new_cases    14346    13571      775 0.05552173
## 259 2021-07-24  new_cases    61423    58168     3255 0.05443553
## 260 2021-02-15  new_cases    55391    52487     2904 0.05383860
## 261 2021-04-24  new_cases    52189    55068     2879 0.05368414
## 262 2020-08-15  new_cases    44136    46541     2405 0.05304542
## 263 2020-07-19  new_cases    58071    61214     3143 0.05269732
## 264 2020-10-21  new_cases    73143    69480     3663 0.05136619
## 265 2020-07-01  new_cases    62056    58987     3069 0.05070925

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     FL tot_deaths  10350041   9728382   621659 0.061923090
## 2     PR tot_deaths    628469    609082    19387 0.031331234
## 3     KY tot_deaths   1849448   1839137    10311 0.005590762
## 4     IN tot_deaths   3811948   3798160    13788 0.003623602
## 5     MS tot_deaths   2215491   2207767     7724 0.003492448
## 6     AL tot_deaths   3073211   3066125     7086 0.002308393
## 7     SC tot_deaths   2563582   2568618     5036 0.001962511
## 8     NM tot_deaths   1126633   1124549     2084 0.001851472
## 9     NC tot_deaths   3458165   3454115     4050 0.001171828
## 10    PR  tot_cases  31617012  33334437  1717425 0.052883347
## 11    PA  tot_cases 273389806 270659767  2730039 0.010035994
## 12    AL  tot_cases 147055558 148145611  1090053 0.007385154
## 13    SC  tot_cases 145835188 146346674   511486 0.003501148
## 14    FL  tot_cases 578444524 576560229  1884295 0.003262835
## 15    MI  tot_cases 242865368 242316039   549329 0.002264427
## 16    FL new_deaths     40473     39179     1294 0.032491337
## 17    MS new_deaths      7791      7544      247 0.032213890
## 18    GA new_deaths     21232     21698      466 0.021709760
## 19    KY new_deaths      7479      7348      131 0.017670466
## 20    AL new_deaths     11734     11542      192 0.016497680
## 21    NM new_deaths      4446      4414       32 0.007223476
## 22    NC new_deaths     13739     13670       69 0.005034843
## 23    IN new_deaths     14058     14012       46 0.003277520
## 24    TN new_deaths     12794     12758       36 0.002817783
## 25    PR new_deaths      2591      2585        6 0.002318393
## 26    SC new_deaths      9972      9958       14 0.001404917
## 27    AL  new_cases    599948    592417     7531 0.012632038
## 28    CA  new_cases   4074510   4037808    36702 0.009048462
## 29    NC  new_cases   1064603   1056699     7904 0.007452027
## 30    WA  new_cases    479286    475881     3405 0.007129643
## 31    FL  new_cases   2659034   2641696    17338 0.006541740
## 32    KY  new_cases    488696    486115     2581 0.005295385
## 33    GA  new_cases   1190936   1185594     5342 0.004495630
## 34    MI  new_cases   1017675   1013112     4563 0.004493824
## 35    PA  new_cases   1232900   1227519     5381 0.004374052
## 36    TN  new_cases    903587    900418     3169 0.003513294
## 37    SD  new_cases    125481    125216      265 0.002114106
## 38    PR  new_cases    148067    147820      247 0.001669556
## 39    SC  new_cases    624678    623861      817 0.001308730
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 35,280
## Columns: 15
## $ date           <date> 2021-01-25, 2020-04-17, 2021-02-02, 2020-07-30, 2020-0~
## $ state          <chr> "NE", "VI", "IL", "ME", "WI", "ND", "GU", "CT", "WI", "~
## $ tot_cases      <dbl> 187923, 54, 1130917, 3910, 25480, 6602, 0, 267337, 9844~
## $ conf_cases     <dbl> NA, NA, 1130917, 3497, 22932, 6602, NA, 250915, 92712, ~
## $ prob_cases     <dbl> NA, NA, 0, 413, 2548, 0, NA, 16422, 5728, NA, 123700, N~
## $ new_cases      <dbl> 646, 1, 2304, 22, 185, 133, 0, 0, 1502, 128, 502, 0, 39~
## $ pnew_case      <dbl> 0, NA, 0, 2, 11, 0, NA, 0, 94, 0, 143, NA, 5, 154, 0, 0~
## $ tot_deaths     <dbl> 1894, 2, 21336, 123, 700, 103, 0, 7381, 1237, 5586, 111~
## $ conf_death     <dbl> NA, NA, 19306, 122, 694, NA, NA, 6049, 1228, NA, 8887, ~
## $ prob_death     <dbl> NA, NA, 2030, 1, 6, NA, NA, 1332, 9, NA, 2265, NA, NA, ~
## $ new_deaths     <dbl> 15, 1, 63, 2, 2, 0, 0, 0, 8, 0, 6, 0, 32, 30, 15, 18, 2~
## $ pnew_death     <dbl> 0, NA, 16, 0, 0, 0, NA, 0, 0, 0, 1, NA, 0, 4, 0, 0, 0, ~
## $ created_at     <chr> "01/27/2021 12:00:00 AM", "04/17/2020 04:22:39 PM", "02~
## $ consent_cases  <chr> "Not agree", NA, "Agree", "Agree", "Agree", "Agree", "N~
## $ consent_deaths <chr> "Not agree", NA, "Agree", "Agree", "Agree", "Not agree"~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_210902.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 32
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta   pctDelta
## 1 2021-07-02        inp    18509    17110     1399 0.07855358
## 2 2021-07-31        inp    51488    48807     2681 0.05346229
## 3 2020-07-25   hosp_ped     3450     4610     1160 0.28784119
## 4 2020-08-02   hosp_ped     4092     4498      406 0.09452852
## 5 2021-07-31   hosp_ped     1313     1247       66 0.05156250
## 6 2021-07-02   hosp_ped      696      662       34 0.05007364
## 7 2021-07-02 hosp_adult    17813    16448     1365 0.07968244
## 8 2021-07-31 hosp_adult    50175    47560     2615 0.05351205

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL        inp   544475   542977     1498 0.002755064
## 2     TX        inp  2869774  2864342     5432 0.001894625
## 3     NC        inp   675079   673836     1243 0.001842963
## 4     PR        inp   153817   153545      272 0.001769900
## 5     NH   hosp_ped      330      285       45 0.146341463
## 6     ME   hosp_ped      467      516       49 0.099694812
## 7     VI   hosp_ped       31       33        2 0.062500000
## 8     KY   hosp_ped     5435     5760      325 0.058061635
## 9     KS   hosp_ped     1718     1819      101 0.057110546
## 10    DE   hosp_ped     1826     1754       72 0.040223464
## 11    NV   hosp_ped     2279     2190       89 0.039829940
## 12    AR   hosp_ped     6174     6372      198 0.031563845
## 13    WV   hosp_ped     2221     2289       68 0.030155211
## 14    IN   hosp_ped     7226     7418      192 0.026222344
## 15    NM   hosp_ped     3202     3279       77 0.023761765
## 16    ID   hosp_ped     1422     1389       33 0.023479189
## 17    MA   hosp_ped     5244     5129      115 0.022172949
## 18    AZ   hosp_ped    11698    11884      186 0.015774743
## 19    SC   hosp_ped     2805     2843       38 0.013456091
## 20    VA   hosp_ped     6956     6870       86 0.012440330
## 21    MO   hosp_ped    16702    16901      199 0.011844181
## 22    IA   hosp_ped     2469     2441       28 0.011405295
## 23    TN   hosp_ped     8139     8223       84 0.010267693
## 24    UT   hosp_ped     3369     3337       32 0.009543692
## 25    MS   hosp_ped     4255     4295       40 0.009356725
## 26    AL   hosp_ped     8314     8385       71 0.008503503
## 27    CO   hosp_ped     9706     9784       78 0.008004105
## 28    MD   hosp_ped     5209     5241       32 0.006124402
## 29    SD   hosp_ped     2503     2489       14 0.005608974
## 30    PR   hosp_ped    11806    11868       62 0.005237814
## 31    LA   hosp_ped     3659     3676       17 0.004635310
## 32    FL   hosp_ped    56499    56703      204 0.003604177
## 33    OH   hosp_ped    28273    28343       70 0.002472799
## 34    TX   hosp_ped    41536    41439       97 0.002338054
## 35    OK   hosp_ped    12409    12436       27 0.002173476
## 36    CT   hosp_ped     2467     2462        5 0.002028809
## 37    OR   hosp_ped     3144     3150        6 0.001906578
## 38    WA   hosp_ped     4613     4621        8 0.001732727
## 39    CA   hosp_ped    32309    32259       50 0.001548755
## 40    IL   hosp_ped    20519    20548       29 0.001412326
## 41    RI   hosp_ped     1454     1452        2 0.001376462
## 42    GA   hosp_ped    22950    22921       29 0.001264415
## 43    NJ   hosp_ped     9322     9311       11 0.001180701
## 44    AL hosp_adult   463714   462110     1604 0.003465021
## 45    PR hosp_adult   120801   120467      334 0.002768705
## 46    TX hosp_adult  2415904  2411369     4535 0.001878908
## 47    VI hosp_adult     1703     1700        3 0.001763150
## 48    KY hosp_adult   310588   310043      545 0.001756277
## 49    ME hosp_adult    38523    38476       47 0.001220795
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 29,378
## Columns: 99
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_210902.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 16,998
## Columns: 69
## $ date                                   <date> 2021-09-01, 2021-09-01, 2021-0~
## $ MMWR_week                              <dbl> 35, 35, 35, 35, 35, 35, 35, 35,~
## $ state                                  <chr> "KS", "NY", "RP", "NC", "IN", "~
## $ Distributed                            <dbl> 3585815, 27518855, 29820, 13316~
## $ Distributed_Janssen                    <dbl> 173500, 1253900, 3800, 646500, ~
## $ Distributed_Moderna                    <dbl> 1498900, 10968420, 20800, 54326~
## $ Distributed_Pfizer                     <dbl> 1913415, 15296535, 5220, 723687~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 123084, 141459, 166527, 126963,~
## $ Distributed_Per_100k_12Plus            <dbl> 146258, 164064, 195004, 148194,~
## $ Distributed_Per_100k_18Plus            <dbl> 162029, 178401, 213809, 162641,~
## $ Distributed_Per_100k_65Plus            <dbl> 754135, 834880, 982861, 760441,~
## $ vxa                                    <dbl> 2919234, 24428883, 29007, 10495~
## $ Administered_12Plus                    <dbl> 2919103, 24426700, 29007, 10481~
## $ Administered_18Plus                    <dbl> 2734777, 22985019, 26820, 98589~
## $ Administered_65Plus                    <dbl> 825173, 5633411, 3180, 2918484,~
## $ Administered_Janssen                   <dbl> 101837, 1072305, 2256, 390218, ~
## $ Administered_Moderna                   <dbl> 1185497, 9356997, 23828, 403072~
## $ Administered_Pfizer                    <dbl> 1630976, 13991672, 2923, 607437~
## $ Administered_Unk_Manuf                 <dbl> 924, 7909, 0, 463, 23170, 19, 8~
## $ Administered_Fed_LTC                   <dbl> 90122, 441057, 0, 228485, 14339~
## $ Administered_Fed_LTC_Residents         <dbl> 45956, 211789, 0, 112435, 91660~
## $ Administered_Fed_LTC_Staff             <dbl> 28092, 156003, 0, 73210, 37398,~
## $ Administered_Fed_LTC_Unk               <dbl> 16074, 73265, 0, 42840, 14337, ~
## $ Administered_Fed_LTC_Dose1             <dbl> 50821, 263888, 0, 137030, 81403~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 24675, 119940, 0, 63622, 50214,~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 16838, 90356, 0, 42876, 21594, ~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 9308, 53592, 0, 30532, 9595, 32~
## $ Admin_Per_100k                         <dbl> 100203, 125575, 161987, 100073,~
## $ Admin_Per_100k_12Plus                  <dbl> 119065, 145629, 189687, 116651,~
## $ Admin_Per_100k_18Plus                  <dbl> 123574, 149009, 192299, 120417,~
## $ Admin_Per_100k_65Plus                  <dbl> 173543, 170909, 104812, 166666,~
## $ Recip_Administered                     <dbl> 3015591, 24362987, 29253, 10393~
## $ Administered_Dose1_Recip               <dbl> 1673114, 13136849, 16802, 58541~
## $ Administered_Dose1_Pop_Pct             <dbl> 57.4, 67.5, 93.8, 55.8, 50.2, 5~
## $ Administered_Dose1_Recip_12Plus        <dbl> 1672986, 13135259, 16802, 58453~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 68.2, 78.3, 99.9, 65.1, 59.3, 6~
## $ Administered_Dose1_Recip_18Plus        <dbl> 1563564, 12335911, 15524, 54900~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 70.7, 80.0, 99.9, 67.1, 61.7, 7~
## $ Administered_Dose1_Recip_65Plus        <dbl> 456535, 2951707, 1761, 1528477,~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 96.0, 89.6, 58.0, 87.3, 85.4, 8~
## $ vxc                                    <dbl> 1408917, 11725228, 14704, 48718~
## $ vxcpoppct                              <dbl> 48.4, 60.3, 82.1, 46.5, 46.4, 4~
## $ Series_Complete_12Plus                 <dbl> 1408894, 11724573, 14704, 48665~
## $ Series_Complete_12PlusPop_Pct          <dbl> 57.5, 69.9, 96.2, 54.2, 54.7, 5~
## $ vxcgte18                               <dbl> 1328055, 11080352, 13791, 46053~
## $ vxcgte18pct                            <dbl> 60.0, 71.8, 98.9, 56.2, 57.3, 5~
## $ vxcgte65                               <dbl> 394170, 2719740, 1687, 1373717,~
## $ vxcgte65pct                            <dbl> 82.9, 82.5, 55.6, 78.4, 82.8, 7~
## $ Series_Complete_Janssen                <dbl> 100534, 1019101, 2260, 383611, ~
## $ Series_Complete_Moderna                <dbl> 550051, 4326607, 11443, 1789647~
## $ Series_Complete_Pfizer                 <dbl> 757989, 6377516, 1001, 2698491,~
## $ Series_Complete_Unk_Manuf              <dbl> 343, 2004, 0, 80, 7008, 31, 757~
## $ Series_Complete_Janssen_12Plus         <dbl> 100527, 1018977, 2260, 383589, ~
## $ Series_Complete_Moderna_12Plus         <dbl> 550044, 4326446, 11443, 1789554~
## $ Series_Complete_Pfizer_12Plus          <dbl> 757980, 6377160, 1001, 2693362,~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 343, 1990, 0, 80, 7008, 31, 757~
## $ Series_Complete_Janssen_18Plus         <dbl> 100443, 1018434, 2260, 382326, ~
## $ Series_Complete_Moderna_18Plus         <dbl> 549764, 4324978, 11443, 1786935~
## $ Series_Complete_Pfizer_18Plus          <dbl> 677527, 5735029, 88, 2436020, 1~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 321, 1911, 0, 78, 6947, 30, 698~
## $ Series_Complete_Janssen_65Plus         <dbl> 16575, 168165, 221, 44400, 2774~
## $ Series_Complete_Moderna_65Plus         <dbl> 189386, 1295280, 1456, 660640, ~
## $ Series_Complete_Pfizer_65Plus          <dbl> 188040, 1255416, 10, 668639, 42~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 169, 879, 0, 38, 3493, 18, 160,~
## $ Series_Complete_FedLTC                 <dbl> 39003, 175255, 0, 90598, 61904,~
## $ Series_Complete_FedLTC_Residents       <dbl> 20959, 90116, 0, 47822, 41207, ~
## $ Series_Complete_FedLTC_Staff           <dbl> 11153, 64362, 0, 29613, 15716, ~
## $ Series_Complete_FedLTC_Unknown         <dbl> 6891, 20777, 0, 13163, 4981, 10~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before   9.39e+9    1.85e+8   3.92e+7 631618       34692    
## 2 after    9.35e+9    1.84e+8   3.90e+7 628537       29988    
## 3 pctchg   4.25e-3    4.13e-3   4.79e-3      0.00488     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 29,988
## Columns: 6
## $ date       <date> 2021-01-25, 2021-02-02, 2020-07-30, 2020-06-15, 2020-07-31~
## $ state      <chr> "NE", "IL", "ME", "WI", "ND", "CT", "WI", "NV", "AL", "MI",~
## $ tot_cases  <dbl> 187923, 1130917, 3910, 25480, 6602, 267337, 98440, 324132, ~
## $ tot_deaths <dbl> 1894, 21336, 123, 700, 103, 7381, 1237, 5586, 11152, 0, 116~
## $ new_cases  <dbl> 646, 2304, 22, 185, 133, 0, 1502, 128, 502, 0, 394, 603, 33~
## $ new_deaths <dbl> 15, 63, 2, 2, 0, 0, 8, 0, 6, 0, 32, 30, 15, 18, 2, 0, 39, 0~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.06e+7    2.46e+7 531377      29378     
## 2 after  3.04e+7    2.45e+7 518452      28311     
## 3 pctchg 5.55e-3    5.50e-3      0.0243     0.0363
## 
## 
## Processed for cdcHosp:
## Rows: 28,311
## Columns: 5
## $ date       <date> 2020-07-24, 2020-07-23, 2020-07-22, 2020-07-22, 2020-07-21~
## $ state      <chr> "ND", "ND", "IA", "ND", "ND", "ND", "KY", "ND", "HI", "LA",~
## $ inp        <dbl> 52, 54, 0, 51, 46, 44, 532, 46, 44, 1521, 42, 205, 50, 841,~
## $ hosp_adult <dbl> NA, NA, 0, NA, NA, NA, 500, NA, 27, 1482, NA, NA, NA, NA, N~
## $ hosp_ped   <dbl> NA, NA, 0, NA, NA, NA, 0, NA, 0, 0, NA, NA, NA, NA, NA, NA,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 1.05e+11 4.47e+10 399452.    1.39e+10 708373.     4.32e+10  490082.   
## 2 after  5.02e+10 2.16e+10 337472.    6.73e+ 9 644868.     2.09e+10  419494.   
## 3 pctchg 5.24e- 1 5.16e- 1      0.155 5.16e- 1      0.0896 5.16e- 1       0.144
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 13,362
## Columns: 9
## $ date        <date> 2021-09-01, 2021-09-01, 2021-09-01, 2021-09-01, 2021-09-0~
## $ state       <chr> "KS", "NY", "NC", "IN", "NV", "TX", "NH", "MD", "FL", "AL"~
## $ vxa         <dbl> 2919234, 24428883, 10495776, 6431733, 3213855, 30268539, 1~
## $ vxc         <dbl> 1408917, 11725228, 4871829, 3121678, 1477405, 13802230, 81~
## $ vxcpoppct   <dbl> 48.4, 60.3, 46.5, 46.4, 48.0, 47.6, 59.7, 61.6, 53.2, 38.4~
## $ vxcgte65    <dbl> 394170, 2719740, 1373717, 898666, 377734, 2913651, 222210,~
## $ vxcgte65pct <dbl> 82.9, 82.5, 78.4, 82.8, 76.2, 78.0, 87.5, 89.3, 82.3, 72.6~
## $ vxcgte18    <dbl> 1328055, 11080352, 4605359, 2961264, 1400878, 12729288, 76~
## $ vxcgte18pct <dbl> 60.0, 71.8, 56.2, 57.3, 58.7, 58.9, 69.6, 73.7, 63.2, 47.4~
## 
## Integrated per capita data file:
## Rows: 30,201
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_210902, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_210902.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The pivoted file and summaries are also created:

hospAge_210902 <- cdc_daily_210902$dfRaw$cdcHosp %>%
    select(state, 
           date, 
           grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
           grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
           ) %>% 
    pivot_longer(-c(state, date)) %>% 
    mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
           adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
           age=ifelse(adultPed=="ped", "0-17", stringr::str_replace_all(string=name, pattern=".*_", replacement="")), 
           age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
           div=as.character(state.division)[match(state, state.abb)]
           ) 
hospAge_210902
## # A tibble: 528,804 x 8
##    state date       name                 value confSusp adultPed age   div      
##    <chr> <date>     <chr>                <dbl> <chr>    <chr>    <chr> <chr>    
##  1 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    0-19  West Nor~
##  2 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    20-29 West Nor~
##  3 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    30-39 West Nor~
##  4 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    40-49 West Nor~
##  5 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    50-59 West Nor~
##  6 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    60-69 West Nor~
##  7 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    70-79 West Nor~
##  8 ND    2020-07-24 previous_day_admiss~    NA confirm~ adult    80+   West Nor~
##  9 ND    2020-07-24 previous_day_admiss~    NA suspect~ adult    0-19  West Nor~
## 10 ND    2020-07-24 previous_day_admiss~    NA suspect~ adult    20-29 West Nor~
## # ... with 528,794 more rows
dfPivot_210902 <- makeCaseHospDeath(dfHosp=hospAge_210902, dfCaseDeath=cdc_daily_210902$dfPerCapita)
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
dfPivot_210902
## # A tibble: 329,742 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 329,732 more rows
# Plot for overall trends by age group
p1 <- hospAge_210902 %>% 
    filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
    mutate(ageBucket=age) %>% 
    group_by(date, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    arrange(date) %>%
    group_by(ageBucket) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-08-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Aug 2021)", 
         subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
         ) + 
    lims(y=c(0, NA))

p1 + geom_line(aes(group=ageBucket, color=ageBucket), size=1) + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 row(s) containing missing values (geom_path).

p1 + geom_col(aes(fill=ageBucket), position="stack") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

p1 + geom_col(aes(fill=ageBucket), position="fill") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Plot for overall trends by age group
hospAge_210902 %>% 
    filter(state %in% state.abb, !is.na(value)) %>% 
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-06-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    geom_line(aes(color=ageBucket, group=ageBucket)) + 
    scale_color_discrete("Age\nbucket") + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Aug 2021)"
         ) + 
    lims(y=c(0, NA)) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 18 row(s) containing missing values (geom_path).

onePageCFRPlot(dfPivot_210902, keyState="FL", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210902, keyState="LA", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210902, keyState="OR", minDate="2020-08-01")

onePageCFRPlot(dfPivot_210902, keyState="HI", minDate="2020-08-01")

The latest data are downloaded and processed, with caching to avoid multiple file downloads:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_211006.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_211006.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_211006.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_210804")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_210804")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_210804")$dfRaw$vax
                    )

cdc_daily_211006 <- readRunCDCDaily(thruLabel="Oct 5, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_211006.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 63
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-02 tot_deaths        0      143      143 2.00000000
## 2   2020-02-03 tot_deaths      244      143      101 0.52196382
## 3   2020-02-04 tot_deaths      244      143      101 0.52196382
## 4   2020-02-05 tot_deaths      244      143      101 0.52196382
## 5   2020-02-06 tot_deaths      244      143      101 0.52196382
## 6   2020-02-07 tot_deaths      244      143      101 0.52196382
## 7   2020-02-08 tot_deaths      245      144      101 0.51928021
## 8   2020-02-09 tot_deaths      245      144      101 0.51928021
## 9   2020-02-10 tot_deaths      245      144      101 0.51928021
## 10  2020-02-11 tot_deaths      245      144      101 0.51928021
## 11  2020-02-12 tot_deaths      245      144      101 0.51928021
## 12  2020-02-13 tot_deaths      245      144      101 0.51928021
## 13  2020-02-14 tot_deaths      245      144      101 0.51928021
## 14  2020-02-15 tot_deaths      245      144      101 0.51928021
## 15  2020-02-16 tot_deaths      245      144      101 0.51928021
## 16  2020-02-17 tot_deaths      245      144      101 0.51928021
## 17  2020-02-18 tot_deaths      245      144      101 0.51928021
## 18  2020-02-19 tot_deaths      246      145      101 0.51662404
## 19  2020-02-20 tot_deaths      246      145      101 0.51662404
## 20  2020-02-21 tot_deaths      246      145      101 0.51662404
## 21  2020-02-22 tot_deaths      246      145      101 0.51662404
## 22  2020-02-23 tot_deaths      246      145      101 0.51662404
## 23  2020-02-24 tot_deaths      246      145      101 0.51662404
## 24  2020-02-25 tot_deaths      246      145      101 0.51662404
## 25  2020-02-26 tot_deaths      246      145      101 0.51662404
## 26  2020-02-27 tot_deaths      247      146      101 0.51399491
## 27  2020-02-28 tot_deaths      247      146      101 0.51399491
## 28  2020-02-29 tot_deaths      248      147      101 0.51139241
## 29  2020-03-01 tot_deaths      248      147      101 0.51139241
## 30  2020-03-02 tot_deaths      254      153      101 0.49631450
## 31  2020-03-03 tot_deaths      257      156      101 0.48910412
## 32  2020-03-04 tot_deaths      259      158      101 0.48441247
## 33  2020-03-05 tot_deaths      262      160      102 0.48341232
## 34  2020-03-06 tot_deaths      266      163      103 0.48018648
## 35  2020-03-07 tot_deaths      271      168      103 0.46924829
## 36  2020-03-08 tot_deaths      276      173      103 0.45879733
## 37  2020-03-09 tot_deaths      280      179      101 0.44008715
## 38  2020-03-10 tot_deaths      286      184      102 0.43404255
## 39  2020-03-11 tot_deaths      300      198      102 0.40963855
## 40  2020-03-12 tot_deaths      307      205      102 0.39843750
## 41  2020-03-13 tot_deaths      318      216      102 0.38202247
## 42  2020-03-14 tot_deaths      332      229      103 0.36720143
## 43  2020-03-15 tot_deaths      352      249      103 0.34276206
## 44  2020-03-16 tot_deaths      373      271      102 0.31677019
## 45  2020-03-17 tot_deaths      405      301      104 0.29461756
## 46  2020-03-18 tot_deaths      476      373      103 0.24263840
## 47  2020-03-19 tot_deaths      541      437      104 0.21267894
## 48  2020-03-20 tot_deaths      643      530      113 0.19266837
## 49  2020-03-21 tot_deaths      758      644      114 0.16262482
## 50  2020-03-22 tot_deaths      893      775      118 0.14148681
## 51  2020-03-23 tot_deaths     1064      946      118 0.11741294
## 52  2020-03-24 tot_deaths     1298     1165      133 0.10799838
## 53  2020-03-25 tot_deaths     1610     1459      151 0.09840339
## 54  2020-03-26 tot_deaths     1963     1804      159 0.08441731
## 55  2020-03-27 tot_deaths     2467     2311      156 0.06529929
## 56  2020-03-28 tot_deaths     3011     2840      171 0.05845155
## 57  2020-03-29 tot_deaths     3592     3403      189 0.05403860
## 58  2020-02-02  tot_cases       20      510      490 1.84905660
## 59  2020-01-22  tot_cases        7       33       26 1.30000000
## 60  2020-01-23  tot_cases        8       35       27 1.25581395
## 61  2020-01-25  tot_cases        9       39       30 1.25000000
## 62  2020-01-24  tot_cases        9       36       27 1.20000000
## 63  2020-01-30  tot_cases       13       47       34 1.13333333
## 64  2020-01-27  tot_cases       12       43       31 1.12727273
## 65  2020-01-26  tot_cases       12       42       30 1.11111111
## 66  2020-01-29  tot_cases       13       45       32 1.10344828
## 67  2020-01-28  tot_cases       13       44       31 1.08771930
## 68  2020-01-31  tot_cases       16       51       35 1.04477612
## 69  2020-02-01  tot_cases       20       55       35 0.93333333
## 70  2020-02-14  tot_cases      617      649       32 0.05055292
## 71  2020-02-15  tot_cases      622      654       32 0.05015674
## 72  2021-07-25 new_deaths      282      136      146 0.69856459
## 73  2021-07-24 new_deaths      305      162      143 0.61241970
## 74  2021-07-18 new_deaths      170       96       74 0.55639098
## 75  2021-07-23 new_deaths      388      226      162 0.52768730
## 76  2021-08-01 new_deaths      386      240      146 0.46645367
## 77  2021-07-26 new_deaths      387      245      142 0.44936709
## 78  2021-07-31 new_deaths      422      274      148 0.42528736
## 79  2021-06-08 new_deaths      315      209      106 0.40458015
## 80  2021-06-07 new_deaths      338      500      162 0.38663484
## 81  2020-11-11 new_deaths     1516     1046      470 0.36690086
## 82  2021-07-17 new_deaths      198      138       60 0.35714286
## 83  2021-08-02 new_deaths      561      392      169 0.35466946
## 84  2021-07-19 new_deaths      264      185       79 0.35189310
## 85  2020-11-12 new_deaths     1367     1863      496 0.30712074
## 86  2020-11-10 new_deaths     1310     1761      451 0.29371540
## 87  2021-07-04 new_deaths      135      101       34 0.28813559
## 88  2021-07-05 new_deaths      141      106       35 0.28340081
## 89  2021-07-27 new_deaths      511      393      118 0.26106195
## 90  2021-07-29 new_deaths      481      370      111 0.26086957
## 91  2021-07-28 new_deaths      459      356      103 0.25276074
## 92  2021-06-17 new_deaths      268      334       66 0.21926910
## 93  2021-05-31 new_deaths      270      218       52 0.21311475
## 94  2021-07-12 new_deaths      229      186       43 0.20722892
## 95  2020-09-30 new_deaths      537      660      123 0.20551378
## 96  2021-07-11 new_deaths      145      118       27 0.20532319
## 97  2021-06-13 new_deaths      165      200       35 0.19178082
## 98  2021-07-15 new_deaths      304      251       53 0.19099099
## 99  2020-10-11 new_deaths      565      675      110 0.17741935
## 100 2021-07-10 new_deaths      154      129       25 0.17667845
## 101 2021-06-21 new_deaths      264      315       51 0.17616580
## 102 2021-07-06 new_deaths      206      173       33 0.17414248
## 103 2021-07-20 new_deaths      320      269       51 0.17317487
## 104 2020-07-13 new_deaths      867      732      135 0.16885553
## 105 2020-10-08 new_deaths      681      803      122 0.16442049
## 106 2021-06-14 new_deaths      221      260       39 0.16216216
## 107 2020-09-24 new_deaths      694      812      118 0.15670651
## 108 2020-07-26 new_deaths      938      802      136 0.15632184
## 109 2020-09-07 new_deaths      557      477       80 0.15473888
## 110 2020-08-02 new_deaths      920      789      131 0.15330603
## 111 2021-06-01 new_deaths      336      391       55 0.15130674
## 112 2021-07-09 new_deaths      271      233       38 0.15079365
## 113 2020-09-23 new_deaths      812      944      132 0.15034169
## 114 2021-06-19 new_deaths      209      180       29 0.14910026
## 115 2021-07-16 new_deaths      303      261       42 0.14893617
## 116 2021-04-11 new_deaths      430      371       59 0.14731586
## 117 2020-08-30 new_deaths      638      552       86 0.14453782
## 118 2021-07-22 new_deaths      334      386       52 0.14444444
## 119 2020-09-10 new_deaths      789      908      119 0.14024750
## 120 2020-07-12 new_deaths      865      753      112 0.13844252
## 121 2020-09-13 new_deaths      713      623       90 0.13473054
## 122 2021-05-29 new_deaths      351      307       44 0.13373860
## 123 2020-10-15 new_deaths      693      792       99 0.13333333
## 124 2021-07-03 new_deaths      162      142       20 0.13157895
## 125 2020-09-09 new_deaths      841      959      118 0.13111111
## 126 2020-09-06 new_deaths      661      580       81 0.13053989
## 127 2020-09-20 new_deaths      473      416       57 0.12823397
## 128 2020-08-09 new_deaths      857      756      101 0.12523249
## 129 2020-07-19 new_deaths      983      869      114 0.12311015
## 130 2021-03-26 new_deaths      845      951      106 0.11804009
## 131 2020-07-20 new_deaths     1029      915      114 0.11728395
## 132 2020-08-17 new_deaths      834      742       92 0.11675127
## 133 2020-09-28 new_deaths      518      462       56 0.11428571
## 134 2021-07-07 new_deaths      240      269       29 0.11394892
## 135 2020-08-04 new_deaths     1217     1087      130 0.11284722
## 136 2021-05-30 new_deaths      265      237       28 0.11155378
## 137 2021-07-30 new_deaths      513      459       54 0.11111111
## 138 2020-07-27 new_deaths     1114      997      117 0.11084794
## 139 2021-06-24 new_deaths      257      287       30 0.11029412
## 140 2021-07-02 new_deaths      272      244       28 0.10852713
## 141 2020-09-17 new_deaths      698      778       80 0.10840108
## 142 2021-06-04 new_deaths      522      469       53 0.10696266
## 143 2020-07-25 new_deaths     1153     1036      117 0.10689813
## 144 2021-06-12 new_deaths      298      268       30 0.10600707
## 145 2021-06-05 new_deaths      320      288       32 0.10526316
## 146 2020-07-05 new_deaths      571      514       57 0.10506912
## 147 2020-07-06 new_deaths      716      645       71 0.10433505
## 148 2020-09-11 new_deaths      797      884       87 0.10350982
## 149 2020-07-09 new_deaths      883      798       85 0.10113028
## 150 2020-09-21 new_deaths      657      596       61 0.09736632
## 151 2020-09-18 new_deaths      773      852       79 0.09723077
## 152 2020-07-04 new_deaths      572      519       53 0.09715857
## 153 2021-06-20 new_deaths      195      177       18 0.09677419
## 154 2020-09-16 new_deaths      985     1085      100 0.09661836
## 155 2021-05-27 new_deaths      510      561       51 0.09523810
## 156 2020-08-06 new_deaths     1236     1126      110 0.09314141
## 157 2020-07-18 new_deaths     1001      912       89 0.09304757
## 158 2021-06-26 new_deaths      192      175       17 0.09264305
## 159 2020-03-20 new_deaths      102       93        9 0.09230769
## 160 2020-10-09 new_deaths      746      816       70 0.08962868
## 161 2020-06-22 new_deaths      583      533       50 0.08960573
## 162 2020-08-23 new_deaths      756      692       64 0.08839779
## 163 2021-06-18 new_deaths      229      210       19 0.08656036
## 164 2020-10-01 new_deaths      705      768       63 0.08553971
## 165 2021-06-30 new_deaths      247      227       20 0.08438819
## 166 2020-10-10 new_deaths      656      603       53 0.08419380
## 167 2021-05-18 new_deaths      603      656       53 0.08419380
## 168 2020-09-03 new_deaths      877      954       77 0.08410705
## 169 2021-04-08 new_deaths      718      781       63 0.08405604
## 170 2020-09-15 new_deaths      793      862       69 0.08338369
## 171 2020-10-13 new_deaths      741      805       64 0.08279431
## 172 2020-08-24 new_deaths      779      718       61 0.08149633
## 173 2020-09-01 new_deaths      959     1040       81 0.08104052
## 174 2020-09-27 new_deaths      489      453       36 0.07643312
## 175 2021-05-25 new_deaths      493      532       39 0.07609756
## 176 2020-09-12 new_deaths      599      646       47 0.07550201
## 177 2020-08-31 new_deaths      688      638       50 0.07541478
## 178 2020-09-25 new_deaths      705      760       55 0.07508532
## 179 2021-06-28 new_deaths      208      193       15 0.07481297
## 180 2020-06-14 new_deaths      491      456       35 0.07391763
## 181 2020-08-18 new_deaths     1033     1112       79 0.07365967
## 182 2021-05-09 new_deaths      385      358       27 0.07267833
## 183 2020-09-29 new_deaths      862      927       65 0.07266629
## 184 2020-07-24 new_deaths     1337     1244       93 0.07206509
## 185 2021-04-05 new_deaths      406      378       28 0.07142857
## 186 2021-06-06 new_deaths      230      247       17 0.07127883
## 187 2020-07-17 new_deaths     1095     1020       75 0.07092199
## 188 2021-06-15 new_deaths      313      336       23 0.07087827
## 189 2020-10-07 new_deaths      791      849       58 0.07073171
## 190 2021-03-25 new_deaths      767      823       56 0.07044025
## 191 2021-07-01 new_deaths      220      236       16 0.07017544
## 192 2021-05-20 new_deaths      504      540       36 0.06896552
## 193 2020-10-25 new_deaths      653      610       43 0.06809184
## 194 2020-09-14 new_deaths      539      504       35 0.06711409
## 195 2021-03-14 new_deaths      635      594       41 0.06672091
## 196 2020-03-24 new_deaths      234      219       15 0.06622517
## 197 2020-07-15 new_deaths     1171     1096       75 0.06616674
## 198 2021-06-16 new_deaths      331      310       21 0.06552262
## 199 2021-03-30 new_deaths      726      775       49 0.06528981
## 200 2020-07-21 new_deaths     1335     1251       84 0.06496520
## 201 2021-03-04 new_deaths     1235     1316       81 0.06350451
## 202 2021-05-04 new_deaths      698      743       45 0.06245663
## 203 2020-08-14 new_deaths     1011     1076       65 0.06229037
## 204 2020-12-25 new_deaths     2491     2341      150 0.06208609
## 205 2020-07-11 new_deaths      881      828       53 0.06202458
## 206 2021-06-25 new_deaths      319      300       19 0.06138934
## 207 2020-10-21 new_deaths     1046     1112       66 0.06116775
## 208 2021-05-17 new_deaths      397      422       25 0.06105006
## 209 2020-08-25 new_deaths      976     1037       61 0.06060606
## 210 2021-04-26 new_deaths      496      527       31 0.06060606
## 211 2021-04-25 new_deaths      426      401       25 0.06045949
## 212 2020-08-01 new_deaths     1144     1077       67 0.06033318
## 213 2021-02-16 new_deaths     1595     1694       99 0.06020067
## 214 2020-03-25 new_deaths      312      294       18 0.05940594
## 215 2020-08-28 new_deaths      954      899       55 0.05936319
## 216 2021-05-12 new_deaths      655      695       40 0.05925926
## 217 2021-05-21 new_deaths      592      628       36 0.05901639
## 218 2021-05-26 new_deaths      497      527       30 0.05859375
## 219 2021-04-16 new_deaths      763      809       46 0.05852417
## 220 2020-06-21 new_deaths      406      383       23 0.05830165
## 221 2021-01-01 new_deaths     3181     3001      180 0.05823358
## 222 2021-02-19 new_deaths     2124     2251      127 0.05805714
## 223 2021-04-06 new_deaths      724      767       43 0.05767941
## 224 2021-06-02 new_deaths      473      501       28 0.05749487
## 225 2020-08-22 new_deaths      898      848       50 0.05727377
## 226 2021-06-10 new_deaths      379      401       22 0.05641026
## 227 2021-06-27 new_deaths      147      139        8 0.05594406
## 228 2020-08-20 new_deaths      975      922       53 0.05587770
## 229 2021-04-17 new_deaths      576      609       33 0.05569620
## 230 2021-05-02 new_deaths      409      387       22 0.05527638
## 231 2021-04-07 new_deaths      734      695       39 0.05458362
## 232 2020-10-02 new_deaths      772      815       43 0.05419030
## 233 2021-03-09 new_deaths     1064     1122       58 0.05306496
## 234 2021-03-16 new_deaths      888      936       48 0.05263158
## 235 2020-06-29 new_deaths      537      510       27 0.05157593
## 236 2020-05-04 new_deaths     1342     1275       67 0.05120367
## 237 2020-07-22 new_deaths     1203     1143       60 0.05115090
## 238 2020-06-27 new_deaths      585      556       29 0.05083260
## 239 2021-06-11 new_deaths      343      326       17 0.05082212
## 240 2021-05-19 new_deaths      570      542       28 0.05035971
## 241 2020-01-22  new_cases        7       33       26 1.30000000
## 242 2020-11-07  new_cases   131834    95671    36163 0.31790950
## 243 2020-02-03  new_cases       26       32        6 0.20689655
## 244 2021-07-29  new_cases   100649    83462    17187 0.18670259
## 245 2020-08-31  new_cases    36951    31737     5214 0.15181691
## 246 2021-07-28  new_cases    96177    84435    11742 0.13002458
## 247 2021-07-26  new_cases    58108    51051     7057 0.12929763
## 248 2020-09-01  new_cases    39455    44538     5083 0.12103390
## 249 2021-07-27  new_cases    87616    77663     9953 0.12043877
## 250 2021-06-06  new_cases    10767    12103     1336 0.11683428
## 251 2021-07-06  new_cases    16896    15036     1860 0.11649756
## 252 2021-06-28  new_cases    10878     9695     1183 0.11500510
## 253 2021-04-12  new_cases    60857    54867     5990 0.10352217
## 254 2020-10-11  new_cases    43258    47898     4640 0.10180350
## 255 2021-07-20  new_cases    53311    48234     5077 0.09999508
## 256 2021-01-02  new_cases   202798   223976    21178 0.09924691
## 257 2021-03-01  new_cases    50563    45900     4663 0.09667956
## 258 2020-07-05  new_cases    41444    45432     3988 0.09180902
## 259 2020-12-26  new_cases   139548   151877    12329 0.08461182
## 260 2021-07-31  new_cases    93240    85965     7275 0.08119193
## 261 2020-05-28  new_cases    26010    24023     1987 0.07942758
## 262 2021-04-18  new_cases    47821    51724     3903 0.07841680
## 263 2020-10-04  new_cases    33811    36560     2749 0.07812877
## 264 2020-11-26  new_cases   153909   166180    12271 0.07667243
## 265 2021-05-22  new_cases    21532    23239     1707 0.07625472
## 266 2020-06-25  new_cases    52825    48970     3855 0.07574046
## 267 2021-07-12  new_cases    24442    22694     1748 0.07416836
## 268 2021-06-05  new_cases    14444    15543     1099 0.07329843
## 269 2020-10-10  new_cases    54240    50606     3634 0.06932072
## 270 2020-06-28  new_cases    42343    45369     3026 0.06899854
## 271 2020-07-11  new_cases    71056    66320     4736 0.06894945
## 272 2021-07-19  new_cases    37654    35205     2449 0.06722574
## 273 2021-04-11  new_cases    50023    53464     3441 0.06650111
## 274 2020-07-13  new_cases    54801    58407     3606 0.06370575
## 275 2021-02-28  new_cases    48788    51996     3208 0.06366090
## 276 2021-04-24  new_cases    51747    55068     3321 0.06218228
## 277 2020-07-15  new_cases    74637    70325     4312 0.05949145
## 278 2020-05-21  new_cases    26254    27823     1569 0.05802837
## 279 2021-02-13  new_cases    80777    85590     4813 0.05786003
## 280 2020-07-07  new_cases    61062    57638     3424 0.05769166
## 281 2020-08-09  new_cases    41266    43702     2436 0.05733923
## 282 2021-07-24  new_cases    61584    58168     3416 0.05705124
## 283 2021-06-11  new_cases    13729    14527      798 0.05648358
## 284 2021-02-15  new_cases    55513    52487     3026 0.05603704
## 285 2021-06-25  new_cases    14327    13571      756 0.05419743
## 286 2020-08-15  new_cases    44116    46541     2425 0.05349835
## 287 2021-07-23  new_cases    70211    66555     3656 0.05346358
## 288 2020-07-19  new_cases    58063    61214     3151 0.05283500
## 289 2020-10-21  new_cases    73061    69480     3581 0.05024519

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     FL tot_deaths  10350964   9728382   622582 0.062012179
## 2     PR tot_deaths    628681    609082    19599 0.031668421
## 3     KY tot_deaths   1851436   1839137    12299 0.006665090
## 4     MP tot_deaths       969       964        5 0.005173306
## 5     IN tot_deaths   3814159   3798160    15999 0.004203450
## 6     CA tot_deaths  16026588  15970217    56371 0.003523539
## 7     MS tot_deaths   2215491   2207767     7724 0.003492448
## 8     AL tot_deaths   3076064   3066125     9939 0.003236305
## 9     NM tot_deaths   1127229   1124549     2680 0.002380341
## 10    NC tot_deaths   3461659   3454115     7544 0.002181679
## 11    SC tot_deaths   2563894   2568618     4724 0.001840814
## 12    PR  tot_cases  31613320  33334437  1721117 0.053000044
## 13    CO  tot_cases 128884494 126439079  2445415 0.019155419
## 14    PA  tot_cases 273389806 270659767  2730039 0.010035994
## 15    AL  tot_cases 146850606 148145611  1295005 0.008779808
## 16    SC  tot_cases 145874578 146346674   472096 0.003231086
## 17    FL  tot_cases 578339105 576560229  1778876 0.003080573
## 18    MI  tot_cases 242865368 242316039   549329 0.002264427
## 19    NE  tot_cases  58248153  58158844    89309 0.001534427
## 20    RI  tot_cases  36690249  36744702    54453 0.001483027
## 21    MP  tot_cases     49822     49883       61 0.001223610
## 22    FL new_deaths     40667     39179     1488 0.037271748
## 23    MS new_deaths      7791      7544      247 0.032213890
## 24    KY new_deaths      7510      7348      162 0.021806434
## 25    GA new_deaths     21232     21698      466 0.021709760
## 26    AL new_deaths     11772     11542      230 0.019730634
## 27    NM new_deaths      4452      4414       38 0.008572073
## 28    NC new_deaths     13776     13670      106 0.007724259
## 29    TN new_deaths     12847     12758       89 0.006951767
## 30    IN new_deaths     14084     14012       72 0.005125285
## 31    PR new_deaths      2592      2585        7 0.002704269
## 32    CA new_deaths     64106     63942      164 0.002561539
## 33    SC new_deaths      9979      9958       21 0.002106636
## 34    MP  new_cases       196       183       13 0.068601583
## 35    AL  new_cases    600718    592417     8301 0.013914603
## 36    CO  new_cases    578677    572616     6061 0.010529031
## 37    CA  new_cases   4076069   4037808    38261 0.009431003
## 38    WA  new_cases    479286    475881     3405 0.007129643
## 39    NC  new_cases   1064245   1056699     7546 0.007115699
## 40    FL  new_cases   2658193   2641696    16497 0.006225413
## 41    KY  new_cases    488931    486115     2816 0.005776138
## 42    GA  new_cases   1190936   1185594     5342 0.004495630
## 43    MI  new_cases   1017675   1013112     4563 0.004493824
## 44    PA  new_cases   1232900   1227519     5381 0.004374052
## 45    TN  new_cases    903665    900418     3247 0.003599613
## 46    SD  new_cases    125481    125216      265 0.002114106
## 47    SC  new_cases    625173    623861     1312 0.002100824
## 48    PR  new_cases    148020    147820      200 0.001352082
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 37,320
## Columns: 15
## $ date           <date> 2021-02-12, 2021-03-01, 2020-08-22, 2020-08-12, 2020-0~
## $ state          <chr> "UT", "CO", "AR", "AS", "HI", "AK", "TX", "OK", "TX", "~
## $ tot_cases      <dbl> 359641, 438745, 56199, 0, 661, 71521, 1867163, 475578, ~
## $ conf_cases     <dbl> 359641, 411869, NA, NA, NA, NA, NA, 373929, NA, 881626,~
## $ prob_cases     <dbl> 0, 26876, NA, NA, NA, NA, NA, 101649, NA, 193571, NA, 4~
## $ new_cases      <dbl> 1060, 677, 547, 0, 8, 235, 24010, 1028, 18811, 1755, 0,~
## $ pnew_case      <dbl> 0, 60, 0, 0, 0, 0, 4196, 264, 3202, 168, 0, 0, 0, 197, ~
## $ tot_deaths     <dbl> 1785, 5952, 674, 0, 17, 377, 33124, 7488, 23357, 34153,~
## $ conf_death     <dbl> 1729, 5218, NA, NA, NA, NA, NA, 6379, NA, 28965, NA, 41~
## $ prob_death     <dbl> 56, 734, NA, NA, NA, NA, NA, 1109, NA, 5188, NA, 167, N~
## $ new_deaths     <dbl> 11, 1, 11, 0, 0, 0, 345, 8, 190, 20, 0, 13, 7, 8, 37, 0~
## $ pnew_death     <dbl> 2, 0, 0, 0, 0, 0, 0, 2, 0, -7, 0, 1, NA, 0, 7, NA, 0, 0~
## $ created_at     <chr> "02/13/2021 02:50:08 PM", "03/01/2021 12:00:00 AM", "08~
## $ consent_cases  <chr> "Agree", "Agree", "Not agree", NA, "Not agree", "N/A", ~
## $ consent_deaths <chr> "Agree", "Agree", "Not agree", NA, "Not agree", "N/A", ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_211006.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses on_hand_supply_therapeutic_b_bamlanivimab_courses on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses previous_week_therapeutic_a_casirivimab_imdevimab_courses_used previous_week_therapeutic_b_bamlanivimab_courses_used previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used icu_patients_confirmed_influenza icu_patients_confirmed_influenza_coverage previous_day_admission_influenza_confirmed previous_day_admission_influenza_confirmed_coverage previous_day_deaths_covid_and_influenza previous_day_deaths_covid_and_influenza_coverage previous_day_deaths_influenza previous_day_deaths_influenza_coverage total_patients_hospitalized_confirmed_influenza total_patients_hospitalized_confirmed_influenza_and_covid total_patients_hospitalized_confirmed_influenza_and_covid_coverage total_patients_hospitalized_confirmed_influenza_coverage
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 66
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference: AS

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta   pctDelta
## 1 2021-07-02        inp    18525    17110     1415 0.07941630
## 2 2021-07-31        inp    51524    48807     2717 0.05416073
## 3 2020-08-02   hosp_ped     4781     4498      283 0.06099795
## 4 2021-07-31   hosp_ped     1313     1247       66 0.05156250
## 5 2021-07-02   hosp_ped      696      662       34 0.05007364
## 6 2021-07-02 hosp_adult    17829    16448     1381 0.08057881
## 7 2021-07-31 hosp_adult    50211    47560     2651 0.05422876

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     GA        inp  1164508  1159071     5437 0.004679849
## 2     NC        inp   675965   673836     2129 0.003154539
## 3     AL        inp   544531   542977     1554 0.002857910
## 4     IA        inp   182179   182542      363 0.001990563
## 5     PR        inp   153806   153545      261 0.001698384
## 6     TX        inp  2867610  2864342     3268 0.001140275
## 7     ME        inp    46767    46818       51 0.001089918
## 8     NH   hosp_ped      330      285       45 0.146341463
## 9     ME   hosp_ped      573      516       57 0.104683196
## 10    VI   hosp_ped       31       33        2 0.062500000
## 11    KS   hosp_ped     1755     1819       64 0.035814214
## 12    KY   hosp_ped     5588     5760      172 0.030313712
## 13    ID   hosp_ped     1422     1389       33 0.023479189
## 14    AR   hosp_ped     6228     6372      144 0.022857143
## 15    NM   hosp_ped     3206     3279       73 0.022513493
## 16    MA   hosp_ped     5244     5129      115 0.022172949
## 17    NV   hosp_ped     2237     2190       47 0.021233341
## 18    DE   hosp_ped     1790     1754       36 0.020316027
## 19    VA   hosp_ped     6990     6870      120 0.017316017
## 20    MS   hosp_ped     4223     4295       72 0.016905377
## 21    NJ   hosp_ped     9458     9311      147 0.015664127
## 22    SC   hosp_ped     2881     2843       38 0.013277428
## 23    UT   hosp_ped     3309     3337       28 0.008426121
## 24    AL   hosp_ped     8448     8385       63 0.007485297
## 25    LA   hosp_ped     3659     3676       17 0.004635310
## 26    PA   hosp_ped    20751    20656       95 0.004588596
## 27    IL   hosp_ped    20634    20548       86 0.004176582
## 28    OH   hosp_ped    28226    28343      117 0.004136541
## 29    TN   hosp_ped     8191     8223       32 0.003899111
## 30    AZ   hosp_ped    11929    11884       45 0.003779448
## 31    NC   hosp_ped    11220    11258       38 0.003381084
## 32    MO   hosp_ped    16846    16901       55 0.003259549
## 33    GA   hosp_ped    22986    22921       65 0.002831812
## 34    IN   hosp_ped     7398     7418       20 0.002699784
## 35    WV   hosp_ped     2294     2289        5 0.002181977
## 36    CT   hosp_ped     2467     2462        5 0.002028809
## 37    PR   hosp_ped    11845    11868       23 0.001939864
## 38    OR   hosp_ped     3144     3150        6 0.001906578
## 39    FL   hosp_ped    56811    56703      108 0.001902849
## 40    OK   hosp_ped    12413    12436       23 0.001851181
## 41    WA   hosp_ped     4613     4621        8 0.001732727
## 42    IA   hosp_ped     2445     2441        4 0.001637331
## 43    RI   hosp_ped     1454     1452        2 0.001376462
## 44    GA hosp_adult   855243   849991     5252 0.006159858
## 45    AL hosp_adult   463636   462110     1526 0.003296801
## 46    ME hosp_adult    38368    38476      108 0.002810890
## 47    IA hosp_adult   153462   153829      367 0.002388615
## 48    PR hosp_adult   120751   120467      284 0.002354716
## 49    NC hosp_adult   571992   570956     1036 0.001812856
## 50    VI hosp_adult     1703     1700        3 0.001763150
## 51    KY hosp_adult   310452   310043      409 0.001318302
## 52    TX hosp_adult  2413855  2411369     2486 0.001030418
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 31,223
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_211006.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: Additional_Doses Additional_Doses_Vax_Pct Additional_Doses_18Plus Additional_Doses_18Plus_Vax_Pct Additional_Doses_50Plus Additional_Doses_50Plus_Vax_Pct Additional_Doses_65Plus Additional_Doses_65Plus_Vax_Pct Additional_Doses_Moderna Additional_Doses_Pfizer Additional_Doses_Janssen Additional_Doses_Unk_Manuf
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 63
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 19,208
## Columns: 81
## $ date                                   <date> 2021-10-05, 2021-10-05, 2021-1~
## $ MMWR_week                              <dbl> 40, 40, 40, 40, 40, 40, 40, 40,~
## $ state                                  <chr> "VA", "NV", "RP", "NE", "MI", "~
## $ Distributed                            <dbl> 12869745, 4045120, 33090, 25822~
## $ Distributed_Janssen                    <dbl> 573200, 199900, 3800, 116400, 6~
## $ Distributed_Moderna                    <dbl> 4833340, 1475340, 22900, 979980~
## $ Distributed_Pfizer                     <dbl> 7463205, 2369880, 6390, 1485870~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 150779, 131328, 184788, 133490,~
## $ Distributed_Per_100k_12Plus            <dbl> 176130, 154288, 216388, 159654,~
## $ Distributed_Per_100k_18Plus            <dbl> 192815, 169428, 237255, 177068,~
## $ Distributed_Per_100k_65Plus            <dbl> 947067, 815594, 1090640, 826431~
## $ vxa                                    <dbl> 11024264, 3443155, 31240, 22012~
## $ Administered_12Plus                    <dbl> 10992921, 3443100, 31240, 22009~
## $ Administered_18Plus                    <dbl> 10178448, 3225317, 28652, 20476~
## $ Administered_65Plus                    <dbl> 2517946, 850914, 3551, 600142, ~
## $ Administered_Janssen                   <dbl> 399119, 151785, 2333, 79234, 37~
## $ Administered_Moderna                   <dbl> 3963920, 1219801, 24444, 817158~
## $ Administered_Pfizer                    <dbl> 6655345, 2071438, 4463, 1300158~
## $ Administered_Unk_Manuf                 <dbl> 5880, 131, 0, 4746, 1616, 1270,~
## $ Administered_Fed_LTC                   <dbl> 217074, 74066, 0, 60654, 295799~
## $ Administered_Fed_LTC_Residents         <dbl> 109722, 16660, 0, 27041, 141181~
## $ Administered_Fed_LTC_Staff             <dbl> 80551, 14302, 0, 23762, 86738, ~
## $ Administered_Fed_LTC_Unk               <dbl> 26801, 43104, 0, 9851, 67880, 1~
## $ Administered_Fed_LTC_Dose1             <dbl> 121472, 50270, 0, 37443, 182161~
## $ Administered_Fed_LTC_Dose1_Residents   <dbl> 58921, 9149, 0, 16713, 81899, 2~
## $ Administered_Fed_LTC_Dose1_Staff       <dbl> 44628, 7977, 0, 15423, 51531, 1~
## $ Administered_Fed_LTC_Dose1_Unk         <dbl> 17923, 33144, 0, 5307, 48731, 9~
## $ Admin_Per_100k                         <dbl> 129158, 111785, 174457, 113797,~
## $ Admin_Per_100k_12Plus                  <dbl> 150444, 131326, 204290, 136077,~
## $ Admin_Per_100k_18Plus                  <dbl> 152494, 135091, 205435, 140410,~
## $ Admin_Per_100k_65Plus                  <dbl> 185292, 171565, 117040, 192071,~
## $ Recip_Administered                     <dbl> 11015106, 3407219, 31501, 22079~
## $ Administered_Dose1_Recip               <dbl> 5877501, 1886012, 17827, 115491~
## $ Administered_Dose1_Pop_Pct             <dbl> 68.9, 61.2, 99.6, 59.7, 57.4, 6~
## $ Administered_Dose1_Recip_12Plus        <dbl> 5859164, 1885912, 17827, 115463~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 80.2, 71.9, 99.9, 71.4, 66.7, 7~
## $ Administered_Dose1_Recip_18Plus        <dbl> 5430306, 1763229, 16486, 107349~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 81.4, 73.9, 99.9, 73.6, 68.9, 7~
## $ Administered_Dose1_Recip_65Plus        <dbl> 1285517, 437932, 1785, 287680, ~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 94.6, 88.3, 58.8, 92.1, 89.0, 9~
## $ vxc                                    <dbl> 5209839, 1575904, 15556, 106388~
## $ vxcpoppct                              <dbl> 61.0, 51.2, 86.9, 55.0, 52.7, 5~
## $ Series_Complete_12Plus                 <dbl> 5197778, 1575865, 15556, 106379~
## $ Series_Complete_12PlusPop_Pct          <dbl> 71.1, 60.1, 99.9, 65.8, 61.2, 6~
## $ vxcgte18                               <dbl> 4823813, 1484340, 14304, 992233~
## $ vxcgte18pct                            <dbl> 72.3, 62.2, 99.9, 68.0, 63.3, 6~
## $ vxcgte65                               <dbl> 1167111, 385863, 1705, 275394, ~
## $ vxcgte65pct                            <dbl> 85.9, 77.8, 56.2, 88.1, 84.1, 8~
## $ Series_Complete_Janssen                <dbl> 390589, 149312, 2338, 79114, 37~
## $ Series_Complete_Moderna                <dbl> 1826509, 552554, 11582, 385208,~
## $ Series_Complete_Pfizer                 <dbl> 2990444, 874003, 1636, 598304, ~
## $ Series_Complete_Unk_Manuf              <dbl> 2297, 35, 0, 1260, 868, 446, 3,~
## $ Series_Complete_Janssen_12Plus         <dbl> 390495, 149308, 2338, 79096, 37~
## $ Series_Complete_Moderna_12Plus         <dbl> 1826340, 552550, 11582, 385188,~
## $ Series_Complete_Pfizer_12Plus          <dbl> 2978651, 873972, 1636, 598257, ~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 2292, 35, 0, 1258, 867, 446, 3,~
## $ Series_Complete_Janssen_18Plus         <dbl> 389060, 149270, 2338, 79040, 37~
## $ Series_Complete_Moderna_18Plus         <dbl> 1821019, 552455, 11582, 385060,~
## $ Series_Complete_Pfizer_18Plus          <dbl> 2611548, 782581, 384, 526920, 2~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 2186, 34, 0, 1213, 810, 398, 3,~
## $ Series_Complete_Janssen_65Plus         <dbl> 67735, 23902, 227, 6449, 66933,~
## $ Series_Complete_Moderna_65Plus         <dbl> 549368, 180305, 1462, 134092, 7~
## $ Series_Complete_Pfizer_65Plus          <dbl> 549284, 181636, 16, 134058, 675~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 724, 20, 0, 795, 509, 207, 3, 1~
## $ Series_Complete_FedLTC                 <dbl> 88584, 23917, 0, 23177, 113757,~
## $ Series_Complete_FedLTC_Residents       <dbl> 45746, 7416, 0, 10273, 58777, 2~
## $ Series_Complete_FedLTC_Staff           <dbl> 32916, 6273, 0, 8304, 34714, 11~
## $ Series_Complete_FedLTC_Unknown         <dbl> 9922, 10228, 0, 4600, 20266, 68~
## $ Additional_Doses                       <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Vax_Pct               <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_18Plus                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_50Plus                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_65Plus                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0~
## $ Additional_Doses_Moderna               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Pfizer                <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Janssen               <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Additional_Doses_Unk_Manuf             <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.08e+10    2.08e+8   4.37e+7 693668       36698    
## 2 after   1.08e+10    2.07e+8   4.35e+7 690216       31722    
## 3 pctchg  4.32e- 3    4.21e-3   4.68e-3      0.00498     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 31,722
## Columns: 6
## $ date       <date> 2021-02-12, 2021-03-01, 2020-08-22, 2020-06-05, 2021-07-27~
## $ state      <chr> "UT", "CO", "AR", "HI", "AK", "TX", "OK", "TX", "GA", "MA",~
## $ tot_cases  <dbl> 359641, 438745, 56199, 661, 71521, 1867163, 475578, 1236648~
## $ tot_deaths <dbl> 1785, 5952, 674, 17, 377, 33124, 7488, 23357, 13, 17427, 21~
## $ new_cases  <dbl> 1060, 677, 547, 8, 235, 24010, 1028, 18811, 115, 1598, 1195~
## $ new_deaths <dbl> 11, 1, 11, 0, 0, 345, 8, 190, 7, 8, 37, 0, 4, 15, 31, 1, 4,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.36e+7    2.76e+7 605791      31223     
## 2 after  3.35e+7    2.75e+7 592135      30045     
## 3 pctchg 5.36e-3    5.26e-3      0.0225     0.0377
## 
## 
## Processed for cdcHosp:
## Rows: 30,045
## Columns: 5
## $ date       <date> 2021-02-02, 2021-01-30, 2021-01-28, 2021-01-26, 2021-01-21~
## $ state      <chr> "LA", "DE", "IA", "DE", "ID", "HI", "MT", "IA", "NV", "NH",~
## $ inp        <dbl> 1276, 352, 397, 368, 248, 119, 164, 548, 1763, 294, 434, 23~
## $ hosp_adult <dbl> 1260, 347, 392, 362, 243, 117, 161, 543, 1755, 291, 432, 23~
## $ hosp_ped   <dbl> 16, 5, 5, 6, 5, 2, 3, 5, 8, 3, 2, 1, 31, 3, 7, 10, 8, 5, 9,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 1.32e+11 5.71e+10 509604     1.70e+10 867745.     5.49e+10  621075.   
## 2 after  6.30e+10 2.76e+10 429668.    8.24e+ 9 788951.     2.65e+10  530761.   
## 3 pctchg 5.23e- 1 5.16e- 1      0.157 5.16e- 1      0.0908 5.17e- 1       0.145
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 15,096
## Columns: 9
## $ date        <date> 2021-10-05, 2021-10-05, 2021-10-05, 2021-10-05, 2021-10-0~
## $ state       <chr> "VA", "NV", "NE", "MI", "KS", "WV", "TN", "MA", "GA", "AL"~
## $ vxa         <dbl> 11024264, 3443155, 2201296, 10788794, 3123280, 1559989, 69~
## $ vxc         <dbl> 5209839, 1575904, 1063886, 5260265, 1501221, 726445, 31367~
## $ vxcpoppct   <dbl> 61.0, 51.2, 55.0, 52.7, 51.5, 40.5, 45.9, 68.2, 45.7, 43.1~
## $ vxcgte65    <dbl> 1167111, 385863, 275394, 1484308, 403394, 262042, 896684, ~
## $ vxcgte65pct <dbl> 85.9, 77.8, 88.1, 84.1, 84.8, 71.4, 78.4, 89.0, 76.5, 75.3~
## $ vxcgte18    <dbl> 4823813, 1484340, 992233, 4968064, 1404254, 695313, 298538~
## $ vxcgte18pct <dbl> 72.3, 62.2, 68.0, 63.3, 63.5, 48.5, 56.1, 78.9, 56.4, 52.7~
## 
## Integrated per capita data file:
## Rows: 31,935
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_211006, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_211006.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

Additional analysis of the resulting data is conducted:

hospAge_211006 <- cdc_daily_211006$dfRaw$cdcHosp %>%
    select(state, 
           date, 
           grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
           grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
           ) %>% 
    pivot_longer(-c(state, date)) %>% 
    mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
           adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
           age=ifelse(adultPed=="ped", "0-17", stringr::str_replace_all(string=name, pattern=".*_", replacement="")), 
           age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
           div=as.character(state.division)[match(state, state.abb)]
           ) 
hospAge_211006
## # A tibble: 562,014 x 8
##    state date       name                 value confSusp adultPed age   div      
##    <chr> <date>     <chr>                <dbl> <chr>    <chr>    <chr> <chr>    
##  1 LA    2021-02-02 previous_day_admiss~     1 confirm~ adult    0-19  West Sou~
##  2 LA    2021-02-02 previous_day_admiss~     8 confirm~ adult    20-29 West Sou~
##  3 LA    2021-02-02 previous_day_admiss~     7 confirm~ adult    30-39 West Sou~
##  4 LA    2021-02-02 previous_day_admiss~    20 confirm~ adult    40-49 West Sou~
##  5 LA    2021-02-02 previous_day_admiss~    23 confirm~ adult    50-59 West Sou~
##  6 LA    2021-02-02 previous_day_admiss~    26 confirm~ adult    60-69 West Sou~
##  7 LA    2021-02-02 previous_day_admiss~    48 confirm~ adult    70-79 West Sou~
##  8 LA    2021-02-02 previous_day_admiss~    30 confirm~ adult    80+   West Sou~
##  9 LA    2021-02-02 previous_day_admiss~     0 suspect~ adult    0-19  West Sou~
## 10 LA    2021-02-02 previous_day_admiss~     2 suspect~ adult    20-29 West Sou~
## # ... with 562,004 more rows
dfPivot_211006 <- makeCaseHospDeath(dfHosp=hospAge_211006, dfCaseDeath=cdc_daily_211006$dfPerCapita)
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
dfPivot_211006
## # A tibble: 349,149 x 4
##    state date       name  value
##    <chr> <date>     <chr> <dbl>
##  1 AL    2020-01-01 0-19     NA
##  2 AL    2020-01-01 20-59    NA
##  3 AL    2020-01-01 60+      NA
##  4 HI    2020-01-01 0-19     NA
##  5 HI    2020-01-01 20-59    NA
##  6 HI    2020-01-01 60+      NA
##  7 IN    2020-01-01 0-19     NA
##  8 IN    2020-01-01 20-59    NA
##  9 IN    2020-01-01 60+      NA
## 10 LA    2020-01-01 0-19     NA
## # ... with 349,139 more rows
# Plot for overall trends by age group
p1 <- hospAge_211006 %>% 
    filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
    mutate(ageBucket=age) %>% 
    group_by(date, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    arrange(date) %>%
    group_by(ageBucket) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-08-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Sep 2021)", 
         subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
         ) + 
    lims(y=c(0, NA))

p1 + geom_line(aes(group=ageBucket, color=ageBucket), size=1) + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 row(s) containing missing values (geom_path).

p1 + geom_col(aes(fill=ageBucket), position="stack") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

p1 + geom_col(aes(fill=ageBucket), position="fill") + 
    scale_color_discrete("Age\nbucket")
## Warning: Removed 24 rows containing missing values (position_stack).

# Plot for overall trends by age group
hospAge_211006 %>% 
    filter(state %in% state.abb, !is.na(value)) %>% 
    mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
    group_by(date, state, ageBucket) %>% 
    summarize(value=sum(value), .groups="drop") %>% 
    group_by(ageBucket, state) %>% 
    mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
    filter(date >= "2020-06-01") %>% 
    ggplot(aes(x=date, y=value7)) + 
    geom_line(aes(color=ageBucket, group=ageBucket)) + 
    scale_color_discrete("Age\nbucket") + 
    labs(x=NULL, 
         y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
         title="Hospital admissions for COVID by age bucket (Aug 2020 - Sep 2021)"
         ) + 
    lims(y=c(0, NA)) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 18 row(s) containing missing values (geom_path).

onePageCFRPlot(dfPivot_211006, keyState="FL", minDate="2020-08-01")

onePageCFRPlot(dfPivot_211006, keyState="LA", minDate="2020-08-01")

onePageCFRPlot(dfPivot_211006, keyState="OR", minDate="2020-08-01")

onePageCFRPlot(dfPivot_211006, keyState="HI", minDate="2020-08-01")

The process is converted to functional form:

createBurdenPivot <- function(lst, 
                              dataThru,
                              minDatePlot="2020-08-01", 
                              plotByState=c(state.abb, "DC")
                              ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list that includes sub-component $dfRaw$cdcHosp
    # dataThru: character string to be used for 'data through'; most commonly MMM-YY
    # minDatePlot: starting date for plots
    # plotByState: states to be facetted for plot of hospitaliztions by age (FALSE means do not create plot)

    # Convert minDatePlot to Date if passed as character
    if ("character" %in% class(minDatePlot)) minDatePlot <- as.Date(minDatePlot)
    
    # Create the hospitalized by age data
    hospAge <- lst[["dfRaw"]][["cdcHosp"]] %>%
        select(state, 
               date, 
               grep(x=names(.), pattern="ed_\\d.*[9+]$", value=TRUE), 
               grep(x=names(.), pattern="pediatric.*ed$", value=TRUE)
               ) %>% 
        pivot_longer(-c(state, date)) %>% 
        mutate(confSusp=ifelse(grepl(x=name, pattern="confirmed"), "confirmed", "suspected"), 
               adultPed=ifelse(grepl(x=name, pattern="adult"), "adult", "ped"), 
               age=ifelse(adultPed=="ped", 
                          "0-17", 
                          stringr::str_replace_all(string=name, pattern=".*_", replacement="")
                          ), 
               age=ifelse(age %in% c("0-17", "18-19"), "0-19", age), 
               div=as.character(state.division)[match(state, state.abb)]
               )

    # Create the pivoted burden data
    dfPivot <- makeCaseHospDeath(dfHosp=hospAge, dfCaseDeath=lst[["dfPerCapita"]])

    # Plot for overall trends by age group
    p1 <- hospAge %>% 
        filter(state %in% c(state.abb, "DC"), !is.na(value)) %>% 
        mutate(ageBucket=age) %>% 
        group_by(date, ageBucket) %>% 
        summarize(value=sum(value), .groups="drop") %>% 
        arrange(date) %>%
        group_by(ageBucket) %>% 
        mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
        filter(date >= minDatePlot) %>% 
        ggplot(aes(x=date, y=value7)) + 
        labs(x=NULL, 
             y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
             title=paste0("Hospital admissions for COVID by age bucket (Aug 2020 - ", dataThru, ")"), 
             subtitle="50 states and DC (includes confirmed and suspected from CDC data)"
             ) + 
        lims(y=c(0, NA))

    # Create three main plots of hospitalized by age data
    print(p1 + geom_line(aes(group=ageBucket, color=ageBucket), size=1) + scale_color_discrete("Age\nbucket"))
    print(p1 + geom_col(aes(fill=ageBucket), position="stack") + scale_color_discrete("Age\nbucket"))
    print(p1 + geom_col(aes(fill=ageBucket), position="fill") + scale_color_discrete("Age\nbucket"))

    # Plot for trends by state and age group
    if (!isFALSE(plotByState)) {
        p2 <- hospAge %>% 
            filter(state %in% plotByState, !is.na(value)) %>% 
            mutate(ageBucket=ifelse(age >= "60", "60+", ifelse(age=="0-19", "0-19", "20-59"))) %>% 
            group_by(date, state, ageBucket) %>% 
            summarize(value=sum(value), .groups="drop") %>% 
            group_by(ageBucket, state) %>% 
            mutate(value7=zoo::rollmean(value, k=7, fill=NA)) %>% 
            filter(date >= minDatePlot) %>% 
            ggplot(aes(x=date, y=value7)) + 
            geom_line(aes(color=ageBucket, group=ageBucket)) + 
            scale_color_discrete("Age\nbucket") + 
            labs(x=NULL, 
                 y="Confirmed or suspected COVID admissions (rolling-7 mean)", 
                 title=paste0("Hospital admissions for COVID by age bucket (Aug 2020 - ", dataThru, ")")
                 ) + 
            lims(y=c(0, NA)) + 
            facet_wrap(~state, scales="free_y")
        print(p2)
    }
    
    # Return key data (do not return plot objects)
    list(hospAge=hospAge, dfPivot=dfPivot)
    
}

burdenPivotList_211006 <- createBurdenPivot(cdc_daily_211006, dataThru="Sep 2021")
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

identical(burdenPivotList_211006$dfPivot, dfPivot_211006)
## [1] TRUE
identical(burdenPivotList_211006$hospAge, hospAge_211006)
## [1] TRUE

Plots for burden growth are also updated:

# Create data
cdcBurdenGrowth_211006 <- cdc_daily_211006$dfPerCapita %>% 
    filter(date %in% c(as.Date(max(date)-2-lubridate::dmonths(c(0, 6, 12)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for cases
p1 <- cdcBurdenGrowth_211006 %>%
    select(state, date, tcpm) %>% 
    mutate(tcpm=round(tcpm/1000)) %>%
    pivot_wider(state, names_from="date", values_from="tcpm") %>%
    tempStackPlot(yVars=c("2021-10-03"="2021-10-03", 
                          "2021-04-03"="2021-04-03", 
                          "2020-10-02"="2020-10-02"
                          ), 
                  yLab="Cumulative cases per thousand", 
                  plotTitle="Evolution of cumulative cases per thousand by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

# Run for deaths
p2 <- cdcBurdenGrowth_211006 %>%
    select(state, date, tdpm) %>% 
    mutate(tdpm=round(tdpm)) %>%
    pivot_wider(state, names_from="date", values_from="tdpm") %>%
    tempStackPlot(yVars=c("2021-10-03"="2021-10-03", 
                          "2021-04-03"="2021-04-03", 
                          "2020-10-02"="2020-10-02"
                          ), 
                  yLab="Cumulative deaths per million", 
                  plotTitle="Evolution of cumulative deaths per million by state", 
                  addSuffix="",
                  scaleName="Date"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

The burden plot is converted to functional form:

cumulativeBurdenPlot <- function(lst, 
                                 keyStates=c(state.abb, "DC"), 
                                 keyDates=NULL, 
                                 ...
                                 ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list file containing dfPerCapita
    # keyStates: states to include in the plot
    # keyDates: dates to include in the burden plot
    #           NULL means default to max(date)-2 from current, 6 months ago, 12 months ago)
    # ...: other arguments to pass to tempStackPlot(), most commonly colorVector
    
    # Get the list of key dates
    if (is.null(keyDates)) {
        keyDates <- as.Date(max(lst[["dfPerCapita"]]$date)-2-lubridate::dmonths(c(0, 6, 12)), origin="1970-01-01")
    }
    
    # Convert to date if needed
    if (!("Date" %in% class(keyDates))) keyDates <- as.Date(keyDates)
    
    # Create data filtered for keyDates and keyStates
    burdenGrowth <- lst[["dfPerCapita"]] %>% 
        filter(date %in% all_of(keyDates), 
               state %in% all_of(keyStates)
               )

    # Create the naming vector for tempStackPlot
    vecName <- as.character(keyDates) %>% purrr::set_names(as.character(keyDates))
    
    # Create plot for cases
    p1 <- burdenGrowth %>%
        select(state, date, tcpm) %>% 
        mutate(tcpm=round(tcpm/1000)) %>%
        pivot_wider(state, names_from="date", values_from="tcpm") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="Cumulative cases per thousand", 
                      plotTitle="Evolution of cumulative cases per thousand by state", 
                      addSuffix="",
                      scaleName="Date", 
                      ...
                      )

    # Create plot for deaths
    p2 <- burdenGrowth %>%
        select(state, date, tdpm) %>% 
        mutate(tdpm=round(tdpm)) %>%
        pivot_wider(state, names_from="date", values_from="tdpm") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="Cumulative deaths per million", 
                      plotTitle="Evolution of cumulative deaths per million by state", 
                      addSuffix="",
                      scaleName="Date", 
                      ...
                      )

    # Print the plots
    gridExtra::grid.arrange(p1, p2, nrow=1)
    
    # Return the burden data
    burdenGrowth
    
}

# Run with general defaults
cumulativeBurdenPlot(cdc_daily_211006)

## # A tibble: 153 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-10-02 AK         8170         73       141          2    39         38
##  2 2020-10-02 AL       165793       4018       868         18   939        925
##  3 2020-10-02 AR        85779       1391       958          7   582        559
##  4 2020-10-02 AZ       219878       5693       552         19   730        585
##  5 2020-10-02 CA       845804      17056      3786         41  3205       3063
##  6 2020-10-02 CO        73614       2057       734          3   336        317
##  7 2020-10-02 CT        58297       4513       555          2   215        214
##  8 2020-10-02 DC        15423        629        65          1   151        136
##  9 2020-10-02 DE        21221        645       174          3   121        121
## 10 2020-10-02 FL       703540      16653      2758         65  2625       2595
## # ... with 143 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>
# Run for specified states and dates
cumulativeBurdenPlot(cdc_daily_211006, 
                     keyStates=state.abb[state.region=="South"], 
                     keyDates=c("2021-09-30", "2021-03-31", "2020-09-30", "2020-03-31")
                     )

## # A tibble: 64 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-03-31 AL         3027         49       211          8   191         NA
##  2 2020-03-31 AR          560          8        56          1   153         NA
##  3 2020-03-31 DE          414         10        70          3    51         NA
##  4 2020-03-31 FL         6516        178       903         31  1251         NA
##  5 2020-03-31 GA         4236        130      1012         27   483         NA
##  6 2020-03-31 KY          841         29       130          7   154         NA
##  7 2020-03-31 LA         5237        239      1212         54   776         NA
##  8 2020-03-31 MD         1660         44         0          8   300         NA
##  9 2020-03-31 MS         2242        153       151         14   131         NA
## 10 2020-03-31 NC         2314         13       210          2   100         NA
## # ... with 54 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>
# Pass a color vector
cumulativeBurdenPlot(cdc_daily_211006, 
                     keyStates=state.abb[state.region=="South"], 
                     keyDates=c("2021-09-30", "2021-06-30", "2021-03-31", 
                                "2020-12-31", "2020-09-30", "2020-06-30"
                                ), 
                     colorVector=c("lightblue", "grey", "green", "orange", "pink", "black")
                     )

## # A tibble: 96 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-06-30 AL        45865       1344      1536         23   973         NA
##  2 2020-06-30 AR        20777        270       520          5   414         NA
##  3 2020-06-30 DE        11728        509        40          2   103         NA
##  4 2020-06-30 FL       156228       3841      6527         53  7008         NA
##  5 2020-06-30 GA        81677       2805      1976         21  1659         NA
##  6 2020-06-30 KY        17073        684       267          6   579         NA
##  7 2020-06-30 LA        58095       3221      1014         22   808        499
##  8 2020-06-30 MD        67918       3316       359         13   862         NA
##  9 2020-06-30 MS        32836       1411       807         19   883         NA
## 10 2020-06-30 NC        71767       1446      2522         17  1029         NA
## # ... with 86 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>

Plots for vaccination are also updated:

# Run for fully vaccinated
tempStackPlot(cdc_daily_211006$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("vxcgte65pct"="65+", 
                      "vxcgte18pct"="18+", 
                      "vxcpoppct"="All"
                      ), 
              yLab="% Fully vaccinated", 
              plotTitle="Fully vaccinated by age cohort and state (as of early-October 2021)"
              )

# Run for first dose
tempStackPlot(cdc_daily_211006$dfRaw$vax %>% filter(date==max(date), state %in% c(state.abb, "DC")), 
              yVars=c("Administered_Dose1_Recip_65PlusPop_Pct"="65+", 
                      "Administered_Dose1_Recip_18PlusPop_Pct"="18+", 
                      "Administered_Dose1_Pop_Pct"="All"
                      ), 
              yLab="% Receiving First Dose", 
              plotTitle="First-dose vaccinated by age cohort and state (as of early-October 2021)"
              )

# Create data
cdcVaxGrowth_211006 <- cdc_daily_211006$dfRaw$vax %>% 
    filter(date %in% c(as.Date(max(date)-lubridate::dmonths(c(0, 3, 6)), origin="1970-01-01")), 
           state %in% c(state.abb, "DC")
           )

# Run for fully vaccinated
p1 <- cdcVaxGrowth_211006 %>%
    select(state, date, vxcpoppct) %>%
    pivot_wider(state, names_from="date", values_from="vxcpoppct") %>%
    tempStackPlot(yVars=c("2021-10-05"="2021-10-05", 
                          "2021-07-05"="2021-07-05", 
                          "2021-04-05"="2021-04-05"
                          ), 
                  yLab="% Fully Vaccinated (all population)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

p2 <- cdcVaxGrowth_211006 %>%
    select(state, date, vxcgte65pct) %>%
    pivot_wider(state, names_from="date", values_from="vxcgte65pct") %>%
    tempStackPlot(yVars=c("2021-10-05"="2021-10-05", 
                          "2021-07-05"="2021-07-05", 
                          "2021-04-05"="2021-04-05"
                          ), 
                  yLab="% Fully Vaccinated (65+)", 
                  plotTitle="Evolution of fully vaccinated rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

# Run for first dose
p1 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Pop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Pop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (all population)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

p2 <- cdcVaxGrowth %>%
    select(state, date, Administered_Dose1_Recip_65PlusPop_Pct) %>%
    pivot_wider(state, names_from="date", values_from="Administered_Dose1_Recip_65PlusPop_Pct") %>%
    tempStackPlot(yVars=c("2021-08-15"="2021-08-15", 
                          "2021-06-15"="2021-06-15", 
                          "2021-04-15"="2021-04-15"
                          ), 
                  yLab="% First-dose (65+)", 
                  plotTitle="Evolution of first dose rate by state"
                  )

gridExtra::grid.arrange(p1, p2, nrow=1)

The process is converted to functional form:

cumulativeVaccinePlot <- function(lst, 
                                 keyStates=c(state.abb, "DC"), 
                                 keyDates=NULL, 
                                 returnData=FALSE,
                                 ...
                                 ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list file containing dfPerCapita
    # keyStates: states to include in the plot
    # keyDates: dates to include in the burden plot
    #           NULL means default to max(date)-2 from current, 6 months ago, 12 months ago)
    # returnData: boolean, should the data be returned?
    # ...: other arguments to pass to tempStackPlot(), most commonly colorVector

    # Get the list of key dates
    if (is.null(keyDates)) {
        keyDates <- as.Date(max(lst[["dfRaw"]][["vax"]]$date)-2-lubridate::dmonths(c(0, 3, 6)), 
                            origin="1970-01-01"
                            )
    }
    
    # Convert to date if needed
    if (!("Date" %in% class(keyDates))) keyDates <- as.Date(keyDates)

    # Chart for fully vaccinated by state
    p5 <- tempStackPlot(lst[["dfRaw"]][["vax"]] %>% filter(date==max(keyDates), state %in% keyStates), 
                        yVars=c("vxcgte65pct"="65+", 
                                "vxcgte18pct"="18+", 
                                "vxcpoppct"="All"
                                ), 
                        yLab="% Fully vaccinated", 
                        plotTitle=paste0("Fully vaccinated by age cohort and state\n(as of ", max(keyDates), ")"), 
                        makeDotPlot=TRUE, 
                        yLims = c(0, 105)
                        )

    # Run for first dose
    p6 <- tempStackPlot(lst[["dfRaw"]][["vax"]] %>% filter(date==max(keyDates), state %in% keyStates), 
                        yVars=c("Administered_Dose1_Recip_65PlusPop_Pct"="65+", 
                                "Administered_Dose1_Recip_18PlusPop_Pct"="18+", 
                                "Administered_Dose1_Pop_Pct"="All"
                                ), 
                        yLab="% Receiving First Dose", 
                        plotTitle=paste0("First-dose vaccinated by age cohort and state\n(as of ", 
                                         max(keyDates), 
                                         ")"
                                         ),
                        makeDotPlot=TRUE,
                        yLims=c(0, 105)
                        )

    gridExtra::grid.arrange(p5, p6, nrow=1)
    
    # Create data filtered for keyDates and keyStates
    burdenGrowth <- lst[["dfRaw"]][["vax"]] %>% 
        filter(date %in% all_of(keyDates), 
               state %in% all_of(keyStates)
               )

    # Create the naming vector for tempStackPlot
    vecName <- as.character(keyDates) %>% purrr::set_names(as.character(keyDates))
    
    # Run for fully vaccinated
    p1 <- burdenGrowth %>%
        select(state, date, vxcpoppct) %>%
        pivot_wider(state, names_from="date", values_from="vxcpoppct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% Fully Vaccinated (all population)", 
                      plotTitle="Evolution of fully vaccinated rate by state", 
                      ...
                      )

    p2 <- burdenGrowth %>%
        select(state, date, vxcgte65pct) %>%
        pivot_wider(state, names_from="date", values_from="vxcgte65pct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% Fully Vaccinated (65+)", 
                      plotTitle="Evolution of fully vaccinated rate by state", 
                      ...
                      )

    gridExtra::grid.arrange(p1, p2, nrow=1)

    # Run for first dose
    p3 <- burdenGrowth %>%
        select(state, date, Administered_Dose1_Pop_Pct) %>%
        pivot_wider(state, names_from="date", values_from="Administered_Dose1_Pop_Pct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% First-dose (all population)", 
                      plotTitle="Evolution of first dose rate by state", 
                      ...
                      )

    p4 <- burdenGrowth %>%
        select(state, date, Administered_Dose1_Recip_65PlusPop_Pct) %>%
        pivot_wider(state, names_from="date", values_from="Administered_Dose1_Recip_65PlusPop_Pct") %>%
        tempStackPlot(yVars=vecName, 
                      yLab="% First-dose (65+)", 
                      plotTitle="Evolution of first dose rate by state", 
                      ...
                      )

    gridExtra::grid.arrange(p3, p4, nrow=1)
    
    # Return the burden data
    if(isTRUE(returnData)) burdenGrowth
    
}


# Run with general defaults
cumulativeVaccinePlot(cdc_daily_211006)

# Run for specified states and dates
cumulativeVaccinePlot(cdc_daily_211006, 
                      keyStates=state.abb[state.region=="South"], 
                      keyDates=c("2021-09-30", "2021-06-30", "2021-03-31", "2020-12-31")
                      )

# Pass a color vector
cumulativeVaccinePlot(cdc_daily_211006, 
                      keyStates=state.abb[state.region=="South"], 
                      keyDates=c("2021-09-30", "2021-08-31", "2021-07-31", 
                                 "2021-06-30", "2021-05-31", "2021-04-30"
                                 ), 
                      colorVector=c("lightblue", "grey", "green", "orange", "pink", "black")
                      )

The functions are integrated for a post-processing capability:

postProcessCDCDaily <- function(lst, 
                                dataThruLabel,
                                keyStates=c(state.abb, "DC"), 
                                keyDatesBurden=NULL, 
                                keyDatesVaccine=NULL,
                                returnData=FALSE,
                                ...
                                ) {
    
    # FUNCTION ARGUMENTS:
    # lst: a processed list file from readRunCDCDaily
    # dataThruLabel: label for when the hospital data are through
    # keyStates: the list of states to be plotted (burden data will be created for all states)
    # keyDatesBurden: key dates to use for the burden plots (NULL means generate automatically)
    # keyDatesVaccine: key dates to use for the vaccine plots (NULL means generate automatically)
    # returnData: should the pivoted data be returned?
    # ...: other arguments passed through to cumulativeBurdenPlot()
    
    # Create the burden data
    burdenPivotList <- createBurdenPivot(lst, dataThru=dataThruLabel)

    # Create the cumulative burden plots
    cumulativeBurdenPlot(lst, 
                         keyStates=keyStates, 
                         keyDates=keyDatesBurden, 
                         ...
                         )
    
    # Create the cumulative vaccines data
    cumulativeVaccinePlot(lst, 
                          keyStates=keyStates, 
                          keyDates=keyDatesVaccine, 
                          ...
                          )
    
    if (isTRUE(returnData)) return(burdenPivotList)
    
}

# Example code
postProcessCDCDaily(cdc_daily_211006, 
                    dataThruLabel="Sep 2021", 
                    keyStates=state.abb[state.region=="South"], 
                    keyDatesBurden=c("2021-09-30", "2021-03-30", "2020-09-30", "2020-03-31"), 
                    keyDatesVaccine=c("2021-09-30", "2021-07-31", "2021-05-31", "2021-03-31")
                    )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

Data from the US Census is downloaded for age estimates by state. Per the documentation, AGE=85 means 85 and over, and AGE=999 means state total, while SEX=0 means total, SEX=1 means male, and SEX=2 means female:

popStateAge <- fileRead("./RInputFiles/sc-est2019-agesex-civ.csv")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   SUMLEV = col_character(),
##   REGION = col_double(),
##   DIVISION = col_double(),
##   STATE = col_double(),
##   NAME = col_character(),
##   SEX = col_double(),
##   AGE = col_double(),
##   ESTBASE2010_CIV = col_double(),
##   POPEST2010_CIV = col_double(),
##   POPEST2011_CIV = col_double(),
##   POPEST2012_CIV = col_double(),
##   POPEST2013_CIV = col_double(),
##   POPEST2014_CIV = col_double(),
##   POPEST2015_CIV = col_double(),
##   POPEST2016_CIV = col_double(),
##   POPEST2017_CIV = col_double(),
##   POPEST2018_CIV = col_double(),
##   POPEST2019_CIV = col_double()
## )
popStateAge
## # A tibble: 13,572 x 18
##    SUMLEV REGION DIVISION STATE NAME    SEX   AGE ESTBASE2010_CIV POPEST2010_CIV
##    <chr>   <dbl>    <dbl> <dbl> <chr> <dbl> <dbl>           <dbl>          <dbl>
##  1 010         0        0     0 Unit~     0     0         3944160        3951430
##  2 010         0        0     0 Unit~     0     1         3978090        3957730
##  3 010         0        0     0 Unit~     0     2         4096939        4090621
##  4 010         0        0     0 Unit~     0     3         4119051        4111688
##  5 010         0        0     0 Unit~     0     4         4063186        4077346
##  6 010         0        0     0 Unit~     0     5         4056872        4064521
##  7 010         0        0     0 Unit~     0     6         4066412        4072904
##  8 010         0        0     0 Unit~     0     7         4030594        4042990
##  9 010         0        0     0 Unit~     0     8         4046497        4025501
## 10 010         0        0     0 Unit~     0     9         4148369        4125312
## # ... with 13,562 more rows, and 9 more variables: POPEST2011_CIV <dbl>,
## #   POPEST2012_CIV <dbl>, POPEST2013_CIV <dbl>, POPEST2014_CIV <dbl>,
## #   POPEST2015_CIV <dbl>, POPEST2016_CIV <dbl>, POPEST2017_CIV <dbl>,
## #   POPEST2018_CIV <dbl>, POPEST2019_CIV <dbl>
# Exploration of the states and ages and sexes included
popStateAge %>% pull(NAME) %>% unique() %>% sort()
##  [1] "Alabama"              "Alaska"               "Arizona"             
##  [4] "Arkansas"             "California"           "Colorado"            
##  [7] "Connecticut"          "Delaware"             "District of Columbia"
## [10] "Florida"              "Georgia"              "Hawaii"              
## [13] "Idaho"                "Illinois"             "Indiana"             
## [16] "Iowa"                 "Kansas"               "Kentucky"            
## [19] "Louisiana"            "Maine"                "Maryland"            
## [22] "Massachusetts"        "Michigan"             "Minnesota"           
## [25] "Mississippi"          "Missouri"             "Montana"             
## [28] "Nebraska"             "Nevada"               "New Hampshire"       
## [31] "New Jersey"           "New Mexico"           "New York"            
## [34] "North Carolina"       "North Dakota"         "Ohio"                
## [37] "Oklahoma"             "Oregon"               "Pennsylvania"        
## [40] "Rhode Island"         "South Carolina"       "South Dakota"        
## [43] "Tennessee"            "Texas"                "United States"       
## [46] "Utah"                 "Vermont"              "Virginia"            
## [49] "Washington"           "West Virginia"        "Wisconsin"           
## [52] "Wyoming"
popStateAge %>% pull(AGE) %>% unique() %>% sort()
##  [1]   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18
## [20]  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37
## [39]  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56
## [58]  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75
## [77]  76  77  78  79  80  81  82  83  84  85 999
popStateAge %>% pull(SEX) %>% unique() %>% sort()
## [1] 0 1 2

The data can then be explored for the total US population estimates over time, as well as the latest population estimates as of 2019:

# Total US population estimates
popStateAge %>%
    filter(AGE==999, NAME=="United States") %>%
    select(state=NAME, SEX, starts_with("POPEST")) %>%
    pivot_longer(-c(state, SEX)) %>%
    mutate(year=as.integer(stringr::str_extract(name, "\\d{4}")), 
           SEX=factor(SEX, levels=c("0", "1", "2"), labels=c("Total", "Male", "Female"))
           ) %>%
    ggplot(aes(x=factor(year))) + 
    geom_line(aes(y=value/1000000, group=SEX, color=SEX)) + 
    geom_text(aes(label=round(value/1000000, 1), 
                  y=value/1000000 + ifelse(SEX=="Male", -5, 5), 
                  color=SEX
                  )
              ) +
    lims(y=c(0, NA)) + 
    labs(x=NULL, y="Population (millions)", title="US Population Estimates by Year")

# Confirmation that US is the sum of the states
popStateAge %>%
    select(-c(SUMLEV, REGION, DIVISION, STATE)) %>%
    pivot_longer(-c(NAME, SEX, AGE)) %>%
    mutate(type=ifelse(NAME=="United States", "United States", "Component")) %>%
    group_by(type, SEX, AGE, name) %>%
    summarize(value=sum(value), .groups="drop") %>%
    pivot_wider(c(SEX, AGE, name), names_from="type", values_from="value") %>%
    mutate(diff=`United States`-Component) %>%
    arrange(-abs(diff))
## # A tibble: 2,871 x 6
##      SEX   AGE name            Component `United States`  diff
##    <dbl> <dbl> <chr>               <dbl>           <dbl> <dbl>
##  1     0     0 ESTBASE2010_CIV   3944160         3944160     0
##  2     0     0 POPEST2010_CIV    3951430         3951430     0
##  3     0     0 POPEST2011_CIV    3963092         3963092     0
##  4     0     0 POPEST2012_CIV    3926570         3926570     0
##  5     0     0 POPEST2013_CIV    3931258         3931258     0
##  6     0     0 POPEST2014_CIV    3954787         3954787     0
##  7     0     0 POPEST2015_CIV    3983981         3983981     0
##  8     0     0 POPEST2016_CIV    3954773         3954773     0
##  9     0     0 POPEST2017_CIV    3893990         3893990     0
## 10     0     0 POPEST2018_CIV    3815343         3815343     0
## # ... with 2,861 more rows
# Using POPEST2019_CIV as the key metric
popStateAge_2019 <- popStateAge %>%
    filter(NAME != "United States") %>%
    select(stateFull=NAME, sex=SEX, age=AGE, pop2019=POPEST2019_CIV) %>%
    mutate(state=c(state.abb, "DC")[match(stateFull, c(state.name, "District of Columbia"))], 
           sex=factor(sex, levels=c("0", "1", "2"), labels=c("Total", "Male", "Female"))
           )
popStateAge_2019
## # A tibble: 13,311 x 5
##    stateFull sex     age pop2019 state
##    <chr>     <fct> <dbl>   <dbl> <chr>
##  1 Alabama   Total     0   56901 AL   
##  2 Alabama   Total     1   58290 AL   
##  3 Alabama   Total     2   59073 AL   
##  4 Alabama   Total     3   59799 AL   
##  5 Alabama   Total     4   60294 AL   
##  6 Alabama   Total     5   59568 AL   
##  7 Alabama   Total     6   58599 AL   
##  8 Alabama   Total     7   59537 AL   
##  9 Alabama   Total     8   60023 AL   
## 10 Alabama   Total     9   60241 AL   
## # ... with 13,301 more rows
# Total Population as of 2019
popStateAge_2019 %>%
    filter(age==999) %>%
    ggplot(aes(x=fct_reorder(state, pop2019, max))) + 
    geom_text(data=~filter(., sex == "Total"), 
              aes(label=paste0(round(pop2019/1000000, 1), " (", state, ")"), y=pop2019/1000000 + 0.1), 
              size=3, 
              hjust=0
              ) +
    geom_col(data=~filter(., sex != "Total"), aes(y=pop2019/1000000, fill=sex), position="stack") + 
    coord_flip() + 
    labs(x=NULL, y="Population (millions)", title="2019 Population by State and Sex")

# Population by Age as of 2019
popStateAge_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(age) %>%
    summarize(pop2019=sum(pop2019)) %>%
    ggplot(aes(x=factor(age))) + 
    geom_text(aes(label=round(pop2019/1000000, 1), y=pop2019/1000000 + 0.1), 
              size=3, 
              hjust=0
              ) +
    geom_col(aes(y=pop2019/1000000)) + 
    labs(x=NULL, y="Population (millions)", title="2019 Population by Age") + 
    coord_flip()

Population totals as well as splits by state, age, and sex seem reasonable. Age buckets are created and plotted by state:

# Add age buckets to data
popStateAgeBucket_2019 <- popStateAge_2019 %>%
    mutate(bucket10=case_when(age==999 ~ "Total", 
                              age <= 19 ~ "0-19", 
                              age >= 80 ~ "80+", 
                              TRUE ~ paste0(floor(age/10)*10, "-", floor(age/10)*10+9)
                              ), 
           bucket03=case_when(age==999 ~ "Total",age <= 19 ~ "0-19", age >= 60 ~ "60+", TRUE ~ "20-59"),
           bucketYMO=case_when(age==999 ~ "Total",age < 18 ~ "0-17", age >= 65 ~ "65+", TRUE ~ "18-64")
           )
popStateAgeBucket_2019
## # A tibble: 13,311 x 8
##    stateFull sex     age pop2019 state bucket10 bucket03 bucketYMO
##    <chr>     <fct> <dbl>   <dbl> <chr> <chr>    <chr>    <chr>    
##  1 Alabama   Total     0   56901 AL    0-19     0-19     0-17     
##  2 Alabama   Total     1   58290 AL    0-19     0-19     0-17     
##  3 Alabama   Total     2   59073 AL    0-19     0-19     0-17     
##  4 Alabama   Total     3   59799 AL    0-19     0-19     0-17     
##  5 Alabama   Total     4   60294 AL    0-19     0-19     0-17     
##  6 Alabama   Total     5   59568 AL    0-19     0-19     0-17     
##  7 Alabama   Total     6   58599 AL    0-19     0-19     0-17     
##  8 Alabama   Total     7   59537 AL    0-19     0-19     0-17     
##  9 Alabama   Total     8   60023 AL    0-19     0-19     0-17     
## 10 Alabama   Total     9   60241 AL    0-19     0-19     0-17     
## # ... with 13,301 more rows
# Proportion by bucketYMO by state
popStateAgeBucket_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(state, bucketYMO) %>%
    summarize(pop2019=sum(pop2019), .groups="drop") %>%
    ggplot(aes(x=fct_reorder2(state, .x=bucketYMO, .y=pop2019, .fun=function(x, y) -sum(y[x=="0-17"])/sum(y)))) + 
    geom_col(aes(y=pop2019, fill=fct_rev(bucketYMO)), position="fill") + 
    coord_flip() + 
    labs(x=NULL, y="Proportion of 2019 population", title="Age distribution by state") + 
    scale_fill_discrete("Age Bucket")

# Proportion by bucket10 by state
popStateAgeBucket_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(state, bucket10) %>%
    summarize(pop2019=sum(pop2019), .groups="drop") %>%
    ggplot(aes(x=fct_reorder2(state, .x=bucket10, .y=pop2019, .fun=function(x, y) -sum(y[x=="0-19"])/sum(y)))) + 
    geom_col(aes(y=pop2019, fill=fct_rev(bucket10)), position="fill") + 
    coord_flip() + 
    labs(x=NULL, y="Proportion of 2019 population", title="Age distribution by state") + 
    scale_fill_discrete("Age Bucket")

# Mean age by state
popStateAgeBucket_2019 %>%
    filter(sex=="Total", age != 999) %>%
    group_by(state) %>%
    summarize(ageMean=sum(age*pop2019)/sum(pop2019), .groups="drop") %>%
    ggplot(aes(x=fct_reorder(state, -ageMean))) + 
    geom_text(aes(y=ageMean+0.2, label=round(ageMean, 1)), hjust=0, size=3) +
    geom_point(aes(y=ageMean)) + 
    coord_flip() + 
    labs(x=NULL, y="Average age", title="Mean age by state", subtitle="(caution that all 85+ counted as 85)") + 
    lims(y=c(0, NA))

There are meaningful differences in age distribution by state. Next steps are to incorporate per-capita metrics in to the hospitalization summaries:

# Integrate vpm in to the pivoted hospital data
burdenPivotList_211006$dfPivot %>%
    filter(name %in% c("0-19", "20-59", "60+"), state %in% c(state.abb, "DC"), !is.na(value)) %>%
    left_join(popStateAgeBucket_2019 %>%
                  filter(sex=="Total") %>%
                  group_by(state, bucket03) %>% 
                  summarize(pop2019=sum(pop2019), .groups="drop"), 
              by=c("state"="state", "name"="bucket03")
              ) %>%
    mutate(vpm=1000000*value/pop2019) %>%
    ggplot(aes(x=date, y=vpm)) + 
    geom_line(aes(group=name, color=name)) + 
    labs(x=NULL, y="Newly hospitalized per million", title="Per capita newly hospitalized by age bucket") +
    facet_wrap(~state, scales="free_y")

There is very significant variability by state that is not fully consistent with other metrics per capita such as cases and deaths. Further exploration is merited.

The hospitalized data in dfPivot was previously divided by total state population. The process is updated to use raw hospital data from hospAge:

ageMap <- popStateAgeBucket_2019 %>% 
    count(bucket10, bucket03) %>%
    filter(bucket10 != "Total") %>%
    select(-n)
ageMap
## # A tibble: 8 x 2
##   bucket10 bucket03
##   <chr>    <chr>   
## 1 0-19     0-19    
## 2 20-29    20-59   
## 3 30-39    20-59   
## 4 40-49    20-59   
## 5 50-59    20-59   
## 6 60-69    60+     
## 7 70-79    60+     
## 8 80+      60+
# Create hospitalized by age bucket by state data
hospBucketState <- burdenPivotList_211006$hospAge %>%
    left_join(ageMap, by=c("age"="bucket10")) %>%
    filter(!is.na(value)) %>%
    group_by(state, date, bucket03) %>%
    summarize(value=sum(value), .groups="drop") %>%
    filter(state %in% c(state.abb, "DC")) %>%
    left_join(popStateAgeBucket_2019 %>%
                  filter(sex=="Total") %>%
                  group_by(state, bucket03) %>% 
                  summarize(pop2019=sum(pop2019), .groups="drop"), 
              by=c("state", "bucket03")
              ) %>%
    mutate(vpm=1000000*value/pop2019) %>%
    group_by(state, bucket03) %>%
    arrange(date) %>%
    mutate(vpm7=zoo::rollmean(vpm, k=7, fill=NA), vpmcum=cumsum(vpm)) %>%
    ungroup()

hospBucketState %>%
    ggplot(aes(x=date, y=vpm7)) + 
    geom_line(aes(group=bucket03, color=bucket03)) + 
    labs(x=NULL, 
         y="Newly hospitalized per million (rolling 7-day mean)", 
         title="Per million newly hospitalized by age bucket"
         ) +
    facet_wrap(~state, scales="free_y") + 
    scale_color_discrete("Age")
## Warning: Removed 18 row(s) containing missing values (geom_path).

hospBucketState %>%
    filter(state != "ND", date >= "2020-07-15") %>%
    ggplot(aes(x=date, y=vpmcum/1000)) + 
    geom_line(aes(group=bucket03, color=bucket03)) + 
    labs(x=NULL, 
         y="Cumulative hospitalized per thousand since 2020-07-15", 
         title="Cumulative newly hospitalized per thousand by age bucket", 
         subtitle="Since 2020-07-15, excludes ND"
         ) +
    facet_wrap(~state, scales="free_y") + 
    scale_color_discrete("Age")

The process to create population data by state and age is converted to functional form:

readPopStateAge <- function(loc) {
    
    # FUNCTION ARGUMENTS:
    # loc: file location on the local computer
    
    # Read the data
    df <- fileRead(loc) %>%
        checkUniqueRows(uniqueBy=c("NAME", "SEX", "AGE"))

    # Confirm that states, ages, and sexes are as expected
    a1 <- all.equal(sort(c(state.name, "District of Columbia", "United States")), 
                    df %>% pull(NAME) %>% unique() %>% sort()
                    )
    print(a1)
    a2 <- all.equal(c(0:85, 999), df %>% pull(AGE) %>% unique() %>% sort())
    print(a2)
    a3 <- all.equal(0:2, df %>% pull(SEX) %>% unique() %>% sort())
    print(a3)
    if(!isTRUE(a1) | !isTRUE(a2) | !isTRUE(a3)) stop("\nUnexpected values for state, age, or sex\n")

    # Plot for total US population estimates
    p1 <- df %>%
        filter(AGE==999, NAME=="United States") %>%
        select(state=NAME, SEX, starts_with("POPEST")) %>%
        pivot_longer(-c(state, SEX)) %>%
        mutate(year=as.integer(stringr::str_extract(name, "\\d{4}")), 
               SEX=factor(SEX, levels=c("0", "1", "2"), labels=c("Total", "Male", "Female"))
               ) %>%
        ggplot(aes(x=factor(year))) + 
        geom_line(aes(y=value/1000000, group=SEX, color=SEX)) + 
        geom_text(aes(label=round(value/1000000, 1), 
                      y=value/1000000 + ifelse(SEX=="Male", -5, 5), 
                      color=SEX
                      )
                  ) +
        lims(y=c(0, NA)) + 
        labs(x=NULL, y="Population (millions)", title="US Population Estimates by Year")
    print(p1)

    componentCheck <- function(vrbl, sumName, descMessage) {
        otherVars <- setdiff(c("NAME", "SEX", "AGE"), vrbl)
        dfCheck <- df %>%
            select(-c(SUMLEV, REGION, DIVISION, STATE)) %>%
            pivot_longer(-c(NAME, SEX, AGE)) %>%
            mutate(across(.cols=all_of(vrbl), .fns=~ifelse(.x==sumName, "Total", "Component"), .names="type")) %>%
            group_by_at(c("type", all_of(otherVars), "name")) %>%
            summarize(value=sum(value), .groups="drop") %>%
            pivot_wider(c(all_of(otherVars), "name"), names_from="type", values_from="value") %>%
            mutate(diff=Total-Component) %>%
            arrange(-abs(diff))
        if(max(abs(dfCheck$diff)) > 0) {
            print(dfCheck)
            stop(paste0("\nFAILED CHECK: ", descMessage, "\n"))
        } else {
            cat("\nPASSED CHECK:", descMessage, "\n\n")
        }
    }
    
    componentCheck("NAME", sumName="United States", descMessage="United States total is the sum of states and DC")
    componentCheck("AGE", sumName=999, descMessage="Age 999 total is the sum of the ages")
    componentCheck("SEX", sumName=0, descMessage="Sex 0 total is the sum of the sexes")

    # Return the data
    df
    
}


filterPopStateAge <- function(df, keyCol, keyColName=keyCol, yearLabel=NULL) {
    
    # FUNCTION ARGUENTS:
    # df: loaded data frame with columns
    # keyCol: the population column to select
    # keyColName: renaming to be applied for the population column (default will leave as-is)
    # yearLabel: label for year to use in plots (NULL means infer from keyCol)

    if (is.null(yearLabel)) yearLabel <- stringr::str_extract(keyCol, pattern="\\d{4}")
    
    # Create the selection and renaming vector
    useCols <- c("stateFull", "sex", "age", all_of(keyColName))
    names(useCols) <- c("NAME", "SEX", "AGE", all_of(keyCol))
    
    # Select the key variable and rename, add state abbreviation, convert sex to more interpretable factor
    dfFilter <- df %>%
        colSelector(names(useCols)) %>%
        colRenamer(useCols) %>%
        mutate(state=c(state.abb, "DC", "US")[match(stateFull, 
                                                    c(state.name, "District of Columbia", "United States")
                                                    )
                                              ], 
               sex=factor(sex, levels=c(0, 1, 2), labels=c("Total", "Male", "Female"))
               )

    # Plot for total population in the key year
    p1 <- dfFilter %>%
        filter(age==999, state != "US") %>%
        ggplot(aes(x=fct_reorder(state, get(keyColName), max))) + 
        geom_text(data=~filter(., sex == "Total"), 
                  aes(label=paste0(round(get(keyColName)/1000000, 1), " (", state, ")"), 
                      y=get(keyColName)/1000000 + 0.1
                      ), 
                  size=3, 
                  hjust=0
                  ) +
        geom_col(data=~filter(., sex != "Total"), aes(y=get(keyColName)/1000000, fill=sex), position="stack") + 
        coord_flip() + 
        labs(x=NULL, y="Population (millions)", title=paste0(yearLabel, " Population by State and Sex"))
    print(p1)
    
    # Population by Age in the key year
    p2 <- dfFilter %>%
        filter(sex=="Total", age != 999, state != "US") %>%
        group_by(age) %>%
        summarize(across(.cols=all_of(keyColName), sum)) %>%
        ggplot(aes(x=factor(age))) + 
        geom_text(aes(label=round(get(keyColName)/1000000, 1), y=get(keyColName)/1000000 + 0.1), 
                  size=3, 
                  hjust=0
                  ) +
        geom_col(aes(y=get(keyColName)/1000000), fill="lightblue") + 
        labs(x=NULL, y="Population (millions)", title=paste0(yearLabel, " Population by Age")) + 
        coord_flip()
    print(p2)

    # Return the data
    dfFilter
    
}


bucketPopStateAge <- function(df, popVar, popYearLabel=NULL) {
    
    # FUNCTION ARGUMENTS:
    # df: a filtered data frame containing the year of interest
    # popVar: name of the population variable
    # popYearLabel: year to use in the plot titles (NULL means infer from popVar)

    # Infer popYearLabel if not provided
    if(is.null(popYearLabel)) popYearLabel <- stringr::str_extract(popVar, pattern="\\d{4}")
    
    # Add age buckets to data
    dfBucket <- df %>%
        mutate(bucket10=case_when(age==999 ~ "Total", 
                                  age <= 19 ~ "0-19", 
                                  age >= 80 ~ "80+", 
                                  TRUE ~ paste0(floor(age/10)*10, "-", floor(age/10)*10+9)
                                  ), 
               bucket03=case_when(age==999 ~ "Total",age <= 19 ~ "0-19", age >= 60 ~ "60+", TRUE ~ "20-59"),
               bucketYMO=case_when(age==999 ~ "Total",age < 18 ~ "0-17", age >= 65 ~ "65+", TRUE ~ "18-64")
               )
    
    # Check that buckets worked as intended
    checkBucket <- function(keyVar) {
        dfBucket %>% 
            count(age, y=get(keyVar)) %>% 
            ggplot(aes(x=factor(age), y=y)) + 
            geom_tile(aes(fill=n)) + 
            coord_flip() + 
            labs(x=NULL, y=NULL, title=paste0("Age map for: ", keyVar))
    }
    p1 <- checkBucket(keyVar="bucket10")
    p2 <- checkBucket(keyVar="bucket03")
    p3 <- checkBucket(keyVar="bucketYMO")
    gridExtra::grid.arrange(p1, p2, p3, nrow=1)
    
    # Proportion by bucketYMO by state
    p4 <- dfBucket %>%
        filter(sex=="Total", age != 999, state != "US") %>%
        group_by(state, bucketYMO) %>%
        summarize(pop=sum(get(popVar)), .groups="drop") %>%
        ggplot(aes(x=fct_reorder2(state, .x=bucketYMO, .y=pop, .fun=function(x, y) -sum(y[x=="0-17"])/sum(y)))) + 
        geom_col(aes(y=pop, fill=fct_rev(bucketYMO)), position="fill") + 
        coord_flip() + 
        labs(x=NULL, 
             y=paste0("Proportion of ", popYearLabel, " population"), 
             title="Age distribution by state"
             ) + 
        scale_fill_discrete("Age Bucket")
    print(p4)
    
    # Proportion by bucket10 by state
    p5 <- dfBucket %>%
        filter(sex=="Total", age != 999, state != "US") %>%
        group_by(state, bucket10) %>%
        summarize(pop=sum(get(popVar)), .groups="drop") %>%
        ggplot(aes(x=fct_reorder2(state, .x=bucket10, .y=pop, .fun=function(x, y) -sum(y[x=="0-19"])/sum(y)))) + 
        geom_col(aes(y=pop, fill=fct_rev(bucket10)), position="fill") + 
        coord_flip() + 
        labs(x=NULL, 
             y=paste0("Proportion of ", popYearLabel, " population"), 
             title="Age distribution by state"
             ) + 
        scale_fill_discrete("Age Bucket")
    print(p5)

    # Mean age by state
    p6 <- dfBucket %>%
        filter(sex=="Total", age != 999, state != "US") %>%
        group_by(state) %>%
        mutate(age=ifelse(age==85, 90, age)) %>%
        summarize(ageMean=sum(age*get(popVar))/sum(get(popVar)), .groups="drop") %>%
        ggplot(aes(x=fct_reorder(state, -ageMean))) + 
        geom_text(aes(y=ageMean+0.2, label=round(ageMean, 1)), hjust=0, size=3) +
        geom_point(aes(y=ageMean)) + 
        coord_flip() + 
        labs(x=NULL, 
             y="Average age", 
             title="Mean age by state", 
             subtitle="(caution that all 85+ counted as 90 for mean calculation)"
             ) + 
        lims(y=c(0, NA))
    print(p6)
    
    # Return the bucketed data
    dfBucket
    
}

dfStateAgeBucket <- readPopStateAge("./RInputFiles/sc-est2019-agesex-civ.csv") %>%
    filterPopStateAge(keyCol="POPEST2019_CIV", keyColName="pop2019") %>%
    bucketPopStateAge(popVar="pop2019")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   SUMLEV = col_character(),
##   REGION = col_double(),
##   DIVISION = col_double(),
##   STATE = col_double(),
##   NAME = col_character(),
##   SEX = col_double(),
##   AGE = col_double(),
##   ESTBASE2010_CIV = col_double(),
##   POPEST2010_CIV = col_double(),
##   POPEST2011_CIV = col_double(),
##   POPEST2012_CIV = col_double(),
##   POPEST2013_CIV = col_double(),
##   POPEST2014_CIV = col_double(),
##   POPEST2015_CIV = col_double(),
##   POPEST2016_CIV = col_double(),
##   POPEST2017_CIV = col_double(),
##   POPEST2018_CIV = col_double(),
##   POPEST2019_CIV = col_double()
## )
## 
## *** File has been checked for uniqueness by: NAME SEX AGE 
## 
## [1] TRUE
## [1] TRUE
## [1] TRUE

## 
## PASSED CHECK: United States total is the sum of states and DC 
## 
## 
## PASSED CHECK: Age 999 total is the sum of the ages 
## 
## 
## PASSED CHECK: Sex 0 total is the sum of the sexes

dfStateAgeBucket
## # A tibble: 13,572 x 8
##    stateFull     sex     age pop2019 state bucket10 bucket03 bucketYMO
##    <chr>         <fct> <dbl>   <dbl> <chr> <chr>    <chr>    <chr>    
##  1 United States Total     0 3783052 US    0-19     0-19     0-17     
##  2 United States Total     1 3829599 US    0-19     0-19     0-17     
##  3 United States Total     2 3922044 US    0-19     0-19     0-17     
##  4 United States Total     3 3998665 US    0-19     0-19     0-17     
##  5 United States Total     4 4043323 US    0-19     0-19     0-17     
##  6 United States Total     5 4028281 US    0-19     0-19     0-17     
##  7 United States Total     6 4017227 US    0-19     0-19     0-17     
##  8 United States Total     7 4022319 US    0-19     0-19     0-17     
##  9 United States Total     8 4066194 US    0-19     0-19     0-17     
## 10 United States Total     9 4061874 US    0-19     0-19     0-17     
## # ... with 13,562 more rows

Age-adjusted plots of hospitaliztion are also created:

hospAgePerCapita <- function(dfBucket, 
                             lst, 
                             popVar, 
                             excludeState=c(), 
                             cumStartDate=NULL
                             ) {
    
    # FUNCTION ARGUMENTS:
    # dfBucket: data frame containing bucketed age data by state
    # lst: a processed list file containing $hospAge
    # popVar: name of the population variable in dfBucket
    # excludeState: list of states to exclude from cumulative plot
    # cumStateDate: data to start the cumulative plots (NULL means use earliest date in data)
    
    # Find cumStartDate if not passed
    if(is.null(cumStartDate)) cumStartDate <- lst[["hospAge"]]$date %>% min()
    
    # Create mapping from bucket10 to bucket03
    ageMap10to03 <- dfBucket %>% 
        count(bucket10, bucket03) %>%
        select(-n)
    
    # Create population by state and bucket03
    popStateBucket03 <- dfBucket %>%
        filter(sex=="Total", state != "US") %>%
        group_by(state, bucket03) %>% 
        summarize(pop=sum(get(popVar)), .groups="drop")
    
    # Create hospitalized by age bucket by state data
    dfUse <- lst[["hospAge"]] %>%
        left_join(ageMap10to03, by=c("age"="bucket10")) %>%
        filter(!is.na(value)) %>%
        group_by(state, date, bucket03) %>%
        summarize(value=sum(value), .groups="drop") %>%
        filter(state %in% c(state.abb, "DC")) %>%
        left_join(popStateBucket03, by=c("state", "bucket03")) %>%
        mutate(vpm=1000000*value/pop) %>%
        group_by(state, bucket03) %>%
        arrange(date) %>%
        mutate(vpm7=zoo::rollmean(vpm, k=7, fill=NA), vpmcum=cumsum(vpm)) %>%
        ungroup()

    p1 <- dfUse %>%
        ggplot(aes(x=date, y=vpm7)) + 
        geom_line(aes(group=bucket03, color=bucket03)) + 
        labs(x=NULL, 
             y="Newly hospitalized per million (rolling 7-day mean)", 
             title="Per million newly hospitalized by age bucket"
             ) +
        facet_wrap(~state, scales="free_y") + 
        scale_color_discrete("Age")
    print(p1)
    
    p2 <- dfUse %>%
        filter(!(state %in% all_of(excludeState)), date >= cumStartDate) %>%
        ggplot(aes(x=date, y=vpmcum/1000)) + 
        geom_line(aes(group=bucket03, color=bucket03)) + 
        labs(x=NULL, 
             y=paste0("Cumulative hospitalized per thousand since ", cumStartDate), 
             title="Cumulative newly hospitalized per thousand by age bucket", 
             subtitle=paste0("Since ", 
                             cumStartDate, 
                             if(length(excludeState) > 0) paste0(", excludes ", paste0(excludeState, collapse=", ")) 
                             else ""
                             )
         ) +
        facet_wrap(~state, scales="free_y") + 
        scale_color_discrete("Age")
    print(p2)
    
    # Return the dataset
    dfUse
    
}

hospAgePerCapita(dfStateAgeBucket, 
                 lst=burdenPivotList_211006, 
                 popVar="pop2019", 
                 excludeState=c("ND"), 
                 cumStartDate="2020-07-15"
                 )
## Warning: Removed 18 row(s) containing missing values (geom_path).

## # A tibble: 68,684 x 8
##    state date       bucket03 value     pop    vpm  vpm7 vpmcum
##    <chr> <date>     <chr>    <dbl>   <dbl>  <dbl> <dbl>  <dbl>
##  1 NV    2020-01-02 0-19         7  760090   9.21    NA   9.21
##  2 NV    2020-01-02 20-59       80 1627729  49.1     NA  49.1 
##  3 NV    2020-01-02 60+        156  681510 229.      NA 229.  
##  4 NV    2020-01-03 0-19         7  760090   9.21    NA  18.4 
##  5 NV    2020-01-03 20-59       80 1627729  49.1     NA  98.3 
##  6 NV    2020-01-03 60+        156  681510 229.      NA 458.  
##  7 AR    2020-01-04 0-19         0  778802   0       NA   0   
##  8 AR    2020-01-04 20-59        0 1521886   0       NA   0   
##  9 AR    2020-01-04 60+          0  711854   0       NA   0   
## 10 NV    2020-01-04 0-19         7  760090   9.21    NA  27.6 
## # ... with 68,674 more rows

The full post-process is converted to functional form, with the option to return key elements in the list:

# Can be run only as-needed
dfStateAgeBucket <- readPopStateAge("./RInputFiles/sc-est2019-agesex-civ.csv") %>%
    filterPopStateAge(keyCol="POPEST2019_CIV", keyColName="pop2019") %>%
    bucketPopStateAge(popVar="pop2019")
## 
## -- Column specification --------------------------------------------------------
## cols(
##   SUMLEV = col_character(),
##   REGION = col_double(),
##   DIVISION = col_double(),
##   STATE = col_double(),
##   NAME = col_character(),
##   SEX = col_double(),
##   AGE = col_double(),
##   ESTBASE2010_CIV = col_double(),
##   POPEST2010_CIV = col_double(),
##   POPEST2011_CIV = col_double(),
##   POPEST2012_CIV = col_double(),
##   POPEST2013_CIV = col_double(),
##   POPEST2014_CIV = col_double(),
##   POPEST2015_CIV = col_double(),
##   POPEST2016_CIV = col_double(),
##   POPEST2017_CIV = col_double(),
##   POPEST2018_CIV = col_double(),
##   POPEST2019_CIV = col_double()
## )
## 
## *** File has been checked for uniqueness by: NAME SEX AGE 
## 
## [1] TRUE
## [1] TRUE
## [1] TRUE

## 
## PASSED CHECK: United States total is the sum of states and DC 
## 
## 
## PASSED CHECK: Age 999 total is the sum of the ages 
## 
## 
## PASSED CHECK: Sex 0 total is the sum of the sexes

# Create pivoted burden data
burdenPivotList_211006 <- postProcessCDCDaily(cdc_daily_211006, 
                                              dataThruLabel="Sep 2021", 
                                              keyStates=state.abb[state.region=="South"], 
                                              keyDatesBurden=c("2021-09-30", "2021-03-30", 
                                                               "2020-09-30", "2020-03-31"
                                                               ),
                                              keyDatesVaccine=c("2021-09-30", "2021-07-31", 
                                                                "2021-05-31", "2021-03-31"
                                                                ), 
                                              returnData=TRUE
                                              )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

# Create hospitalized per capita data
hospAgePerCapita(dfStateAgeBucket, 
                 lst=burdenPivotList_211006, 
                 popVar="pop2019", 
                 excludeState=c("ND"), 
                 cumStartDate="2020-07-15"
                 )
## Warning: Removed 18 row(s) containing missing values (geom_path).

## # A tibble: 68,684 x 8
##    state date       bucket03 value     pop    vpm  vpm7 vpmcum
##    <chr> <date>     <chr>    <dbl>   <dbl>  <dbl> <dbl>  <dbl>
##  1 NV    2020-01-02 0-19         7  760090   9.21    NA   9.21
##  2 NV    2020-01-02 20-59       80 1627729  49.1     NA  49.1 
##  3 NV    2020-01-02 60+        156  681510 229.      NA 229.  
##  4 NV    2020-01-03 0-19         7  760090   9.21    NA  18.4 
##  5 NV    2020-01-03 20-59       80 1627729  49.1     NA  98.3 
##  6 NV    2020-01-03 60+        156  681510 229.      NA 458.  
##  7 AR    2020-01-04 0-19         0  778802   0       NA   0   
##  8 AR    2020-01-04 20-59        0 1521886   0       NA   0   
##  9 AR    2020-01-04 60+          0  711854   0       NA   0   
## 10 NV    2020-01-04 0-19         7  760090   9.21    NA  27.6 
## # ... with 68,674 more rows

The full process is run with the latest data and cached:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_211024.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_211024.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_211024.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_211006")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_211006")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_211006")$dfRaw$vax
                    )

cdc_daily_211024 <- readRunCDCDaily(thruLabel="Oct 23, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_211024.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 18
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##          date       name newValue refValue absDelta   pctDelta
## 1  2020-02-03 tot_deaths      269      244       25 0.09746589
## 2  2020-02-04 tot_deaths      269      244       25 0.09746589
## 3  2020-02-05 tot_deaths      269      244       25 0.09746589
## 4  2020-02-06 tot_deaths      269      244       25 0.09746589
## 5  2020-02-07 tot_deaths      269      244       25 0.09746589
## 6  2020-02-08 tot_deaths      270      245       25 0.09708738
## 7  2020-02-09 tot_deaths      270      245       25 0.09708738
## 8  2020-02-10 tot_deaths      270      245       25 0.09708738
## 9  2020-02-11 tot_deaths      270      245       25 0.09708738
## 10 2020-02-12 tot_deaths      270      245       25 0.09708738
## 11 2020-02-13 tot_deaths      270      245       25 0.09708738
## 12 2020-02-14 tot_deaths      270      245       25 0.09708738
## 13 2020-02-15 tot_deaths      270      245       25 0.09708738
## 14 2020-02-16 tot_deaths      270      245       25 0.09708738
## 15 2020-02-17 tot_deaths      270      245       25 0.09708738
## 16 2020-02-18 tot_deaths      270      245       25 0.09708738
## 17 2020-02-19 tot_deaths      271      246       25 0.09671180
## 18 2020-02-20 tot_deaths      271      246       25 0.09671180
## 19 2020-02-21 tot_deaths      271      246       25 0.09671180
## 20 2020-02-22 tot_deaths      271      246       25 0.09671180
## 21 2020-02-23 tot_deaths      271      246       25 0.09671180
## 22 2020-02-24 tot_deaths      271      246       25 0.09671180
## 23 2020-02-25 tot_deaths      271      246       25 0.09671180
## 24 2020-02-26 tot_deaths      271      246       25 0.09671180
## 25 2020-02-27 tot_deaths      272      247       25 0.09633911
## 26 2020-02-28 tot_deaths      272      247       25 0.09633911
## 27 2020-02-29 tot_deaths      273      248       25 0.09596929
## 28 2020-03-01 tot_deaths      273      248       25 0.09596929
## 29 2020-03-02 tot_deaths      279      254       25 0.09380863
## 30 2020-03-03 tot_deaths      282      257       25 0.09276438
## 31 2020-03-04 tot_deaths      284      259       25 0.09208103
## 32 2020-03-05 tot_deaths      287      262       25 0.09107468
## 33 2020-03-06 tot_deaths      291      266       25 0.08976661
## 34 2020-03-07 tot_deaths      296      271       25 0.08818342
## 35 2020-03-08 tot_deaths      301      276       25 0.08665511
## 36 2020-03-09 tot_deaths      305      280       25 0.08547009
## 37 2020-03-10 tot_deaths      311      286       25 0.08375209
## 38 2020-03-11 tot_deaths      325      300       25 0.08000000
## 39 2020-03-12 tot_deaths      332      307       25 0.07824726
## 40 2020-03-13 tot_deaths      343      318       25 0.07564297
## 41 2020-03-14 tot_deaths      357      332       25 0.07256894
## 42 2020-03-15 tot_deaths      377      352       25 0.06858711
## 43 2020-03-16 tot_deaths      398      373       25 0.06485084
## 44 2020-03-17 tot_deaths      430      405       25 0.05988024
## 45 2020-03-18 tot_deaths      501      476       25 0.05117707
## 46 2021-10-03 new_deaths      910      687      223 0.27927364
## 47 2021-09-26 new_deaths     1068      817      251 0.26631300
## 48 2021-09-25 new_deaths     1385     1116      269 0.21511395
## 49 2021-10-02 new_deaths     1164      997      167 0.15455807
## 50 2021-09-19 new_deaths     1202     1036      166 0.14834674
## 51 2021-09-27 new_deaths     1307     1127      180 0.14790468
## 52 2021-09-21 new_deaths     2208     1930      278 0.13436443
## 53 2021-09-24 new_deaths     2198     1925      273 0.13242784
## 54 2021-09-28 new_deaths     1987     1754      233 0.12456562
## 55 2021-09-23 new_deaths     1943     1730      213 0.11598149
## 56 2021-09-22 new_deaths     2016     1802      214 0.11210058
## 57 2021-09-18 new_deaths     1500     1358      142 0.09937019
## 58 2021-09-12 new_deaths     1283     1192       91 0.07353535
## 59 2021-09-20 new_deaths     1334     1247       87 0.06741573
## 60 2021-09-13 new_deaths     1364     1276       88 0.06666667
## 61 2021-09-17 new_deaths     2102     1973      129 0.06331288
## 62 2021-09-16 new_deaths     1947     1832      115 0.06086266
## 63 2021-09-11 new_deaths     1572     1481       91 0.05961349
## 64 2021-08-01 new_deaths      408      386       22 0.05541562
## 65 2021-09-15 new_deaths     2109     1996      113 0.05505481
## 66 2021-09-05 new_deaths     1245     1184       61 0.05022643
## 67 2021-10-03  new_cases    74729    70013     4716 0.06516422

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     AL tot_deaths  3924524  3909338    15186 0.003877015
## 2     KY tot_deaths  2373233  2364995     8238 0.003477249
## 3     FL tot_deaths 13520925 13485213    35712 0.002644732
## 4     CA tot_deaths 20286061 20243442    42619 0.002103110
## 5     TN tot_deaths  3992595  3988072     4523 0.001133489
## 6     NM tot_deaths  1421364  1419795     1569 0.001104479
## 7     FL new_deaths    57919    55622     2297 0.040461155
## 8     KY new_deaths     9155     8906      249 0.027573224
## 9     AL new_deaths    14858    14542      316 0.021496599
## 10    TN new_deaths    15592    15323      269 0.017402555
## 11    CA new_deaths    69969    68795     1174 0.016920815
## 12    IN new_deaths    15986    15773      213 0.013413521
## 13    NM new_deaths     4869     4823       46 0.009492365
## 14    SC new_deaths    12933    12828      105 0.008151857
## 15    MS new_deaths     8856     8906       50 0.005629997
## 16    PR new_deaths     3181     3173        8 0.002518099
## 17    RI new_deaths     2846     2843        3 0.001054667
## 18    KY  new_cases   705033   700393     4640 0.006602980
## 19    CA  new_cases  4743900  4724440    19460 0.004110541
## 20    TN  new_cases  1242274  1238023     4251 0.003427815
## 21    SC  new_cases   868617   866245     2372 0.002734511
## 22    AL  new_cases   805018   802977     2041 0.002538565
## 23    PR  new_cases   181993   181797      196 0.001077545
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 38,400
## Columns: 15
## $ date           <date> 2021-09-01, 2021-01-13, 2020-04-17, 2020-07-30, 2021-0~
## $ state          <chr> "ND", "IN", "VI", "ME", "MS", "NH", "NV", "NE", "NC", "~
## $ tot_cases      <dbl> 118491, 574488, 54, 3910, 280182, 2518, 320719, 20150, ~
## $ conf_cases     <dbl> 107475, NA, NA, 3497, 176228, NA, 320719, NA, 760095, N~
## $ prob_cases     <dbl> 11016, NA, NA, 413, 103954, NA, 0, NA, 115264, NA, 2026~
## $ new_cases      <dbl> 536, 3654, 1, 22, 1059, 89, 180, 179, 1614, 0, 621, 275~
## $ pnew_case      <dbl> 66, 0, NA, 2, 559, 0, 0, 0, 450, NA, -11, 0, 0, NA, 163~
## $ tot_deaths     <dbl> 1562, 10920, 2, 123, 6730, 86, 5530, 282, 12363, 0, 328~
## $ conf_death     <dbl> NA, 10553, NA, 122, 4739, NA, NA, NA, 10933, NA, 2524, ~
## $ prob_death     <dbl> NA, 367, NA, 1, 1991, NA, NA, NA, 1430, NA, 761, 250, N~
## $ new_deaths     <dbl> 1, 74, 1, 2, 13, 2, 0, -1, 16, 0, 66, 40, 33, 0, 16, 15~
## $ pnew_death     <dbl> 0, 1, NA, 0, 7, 0, 0, 0, 2, NA, 8, 0, 0, NA, 3, 0, 0, 2~
## $ created_at     <chr> "09/02/2021 01:49:05 PM", "01/13/2021 12:00:00 AM", "04~
## $ consent_cases  <chr> "Agree", "Not agree", NA, "Agree", "Agree", "Not agree"~
## $ consent_deaths <chr> "Not agree", "Agree", NA, "Agree", "Agree", "Not agree"~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_211024.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 19
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta   pctDelta
## 1 2020-08-02 hosp_ped     4135     4781      646 0.14490803
## 2 2020-07-25 hosp_ped     4082     4407      325 0.07656968

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     UT        inp   168050   167794      256 0.001524517
## 2     NH   hosp_ped      336      380       44 0.122905028
## 3     ME   hosp_ped      664      722       58 0.083694084
## 4     WV   hosp_ped     2824     3069      245 0.083149499
## 5     VT   hosp_ped      113      109        4 0.036036036
## 6     SC   hosp_ped     4747     4918      171 0.035385411
## 7     KS   hosp_ped     2473     2528       55 0.021995601
## 8     DE   hosp_ped     2475     2436       39 0.015882712
## 9     AR   hosp_ped     7856     7774       82 0.010492642
## 10    NJ   hosp_ped    10600    10704      104 0.009763425
## 11    TN   hosp_ped    11961    11849      112 0.009407812
## 12    AZ   hosp_ped    15019    15159      140 0.009278282
## 13    IN   hosp_ped     9881     9966       85 0.008565526
## 14    MA   hosp_ped     5780     5731       49 0.008513596
## 15    UT   hosp_ped     3907     3876       31 0.007966080
## 16    MO   hosp_ped    21184    21343      159 0.007477602
## 17    NM   hosp_ped     3935     3906       29 0.007397016
## 18    VA   hosp_ped     9061     9114       53 0.005832187
## 19    MS   hosp_ped     6363     6333       30 0.004725898
## 20    AK   hosp_ped     1059     1064        5 0.004710316
## 21    MD   hosp_ped     6786     6815       29 0.004264392
## 22    GA   hosp_ped    30214    30330      116 0.003831924
## 23    CO   hosp_ped    11892    11848       44 0.003706824
## 24    RI   hosp_ped     1705     1699        6 0.003525264
## 25    IA   hosp_ped     3553     3541       12 0.003383141
## 26    FL   hosp_ped    68359    68589      230 0.003358939
## 27    WA   hosp_ped     6319     6300       19 0.003011332
## 28    OK   hosp_ped    15596    15557       39 0.002503772
## 29    ND   hosp_ped     1779     1783        4 0.002245929
## 30    AL   hosp_ped    12216    12189       27 0.002212661
## 31    WY   hosp_ped      467      468        1 0.002139037
## 32    PR   hosp_ped    13592    13618       26 0.001911062
## 33    TX   hosp_ped    61576    61459      117 0.001901898
## 34    NV   hosp_ped     2739     2744        5 0.001823819
## 35    NE   hosp_ped     4153     4146        7 0.001686950
## 36    PA   hosp_ped    25406    25444       38 0.001494592
## 37    MN   hosp_ped     7296     7305        9 0.001232792
## 38    WV hosp_adult   176432   176179      253 0.001435009
## 39    NH hosp_adult    47027    46970       57 0.001212805
## 40    NV hosp_adult   418591   418168      423 0.001011044
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 32,249
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_211024.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: Administered_Fed_LTC Administered_Fed_LTC_Residents Administered_Fed_LTC_Staff Administered_Fed_LTC_Unk Administered_Fed_LTC_Dose1 Administered_Fed_LTC_Dose1_Residents Administered_Fed_LTC_Dose1_Staff Administered_Fed_LTC_Dose1_Unk Series_Complete_FedLTC Series_Complete_FedLTC_Residents Series_Complete_FedLTC_Staff Series_Complete_FedLTC_Unknown
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 19
## 
## Checking for similarity of: state
## In reference but not in current: LTC
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
##           date name  newValue  refValue absDelta   pctDelta
## 1   2021-02-05  vxa  73638424  78058057  4419633 0.05826942
## 2   2021-01-22  vxa  38215918  40505202  2289284 0.05816188
## 3   2021-02-04  vxa  70407420  74617447  4210027 0.05805938
## 4   2021-01-25  vxa  45468486  48182973  2714487 0.05796999
## 5   2021-01-21  vxa  35092748  37181929  2089181 0.05781225
## 6   2021-01-29  vxa  55769322  59083588  3314266 0.05771323
## 7   2021-02-03  vxa  67756508  71778915  4022407 0.05765428
## 8   2021-01-23  vxa  41075980  43513650  2437670 0.05763520
## 9   2021-02-06  vxa  78075928  82704890  4628962 0.05758102
## 10  2021-01-30  vxa  59155804  62661235  3505431 0.05755239
## 11  2021-01-28  vxa  52387364  55489498  3102134 0.05751250
## 12  2021-01-31  vxa  62246598  65930316  3683718 0.05747865
## 13  2021-01-27  vxa  49305268  52210108  2904840 0.05722956
## 14  2021-02-02  vxa  65561720  69413180  3851460 0.05706928
## 15  2021-01-24  vxa  43697310  46264328  2567018 0.05706917
## 16  2021-02-07  vxa  82421874  87261018  4839144 0.05703750
## 17  2021-02-08  vxa  84835234  89781717  4946483 0.05665524
## 18  2021-02-01  vxa  64444804  68193583  3748779 0.05652631
## 19  2021-02-09  vxa  86412380  91427604  5015224 0.05640153
## 20  2021-01-26  vxa  47081988  49807818  2725830 0.05626660
## 21  2021-02-10  vxa  89539940  94716439  5176499 0.05618800
## 22  2021-01-20  vxa  33050538  34958794  1908256 0.05611748
## 23  2021-02-11  vxa  92780540  98129315  5348775 0.05603456
## 24  2021-01-19  vxa  32167926  34010489  1842563 0.05568471
## 25  2021-01-16  vxa  28117300  29717126  1599826 0.05532435
## 26  2021-02-12  vxa  96821116 102328901  5507785 0.05531293
## 27  2021-01-17  vxa  29829518  31522857  1693339 0.05520044
## 28  2021-01-15  vxa  25835214  27291672  1456458 0.05482941
## 29  2021-01-18  vxa  30925618  32660620  1735002 0.05457162
## 30  2021-02-13  vxa 101283768 106950859  5667091 0.05442986
## 31  2021-02-14  vxa 105768712 111591583  5822871 0.05357806
## 32  2021-01-14  vxa  23922748  25234457  1311709 0.05336792
## 33  2021-02-15  vxa 108521140 114435230  5914090 0.05305155
## 34  2021-02-16  vxa 110440728 116409270  5968542 0.05262105
## 35  2021-02-17  vxa 112563654 118633995  6070341 0.05251213
## 36  2021-01-13  vxa  21735014  22899854  1164840 0.05219417
## 37  2021-02-18  vxa 115475534 121657530  6181996 0.05213947
## 38  2021-01-12  vxa  19760044  20792808  1032764 0.05093422
## 39  2021-02-19  vxa 122008442 128297630  6289188 0.05025198
## 40  2021-02-20  vxa 125486643 131885653  6399010 0.04972571
## 41  2021-02-21  vxa 129171433 135691281  6519848 0.04923191
## 42  2021-02-22  vxa 131411783 137991019  6579236 0.04884311
## 43  2021-01-11  vxa  18726328  19663344   937016 0.04881605
## 44  2021-01-10  vxa  17887448  18780252   892804 0.04869703
## 45  2021-02-23  vxa 133182811 139810631  6627820 0.04855662
## 46  2021-02-24  vxa 136109901 142834211  6724310 0.04821260
## 47  2021-01-09  vxa  16433258  17243018   809760 0.04809083
## 48  2021-02-25  vxa 139808950 146626410  6817460 0.04760208
## 49  2021-02-26  vxa 144257510 151190581  6933071 0.04693258
## 50  2021-02-27  vxa 149124582 156168122  7043540 0.04614286
## 51  2021-01-08  vxa  14852290  15545536   693246 0.04561155
## 52  2021-02-28  vxa 154092179 161204716  7112537 0.04511644
## 53  2021-01-07  vxa  13111360  13714673   603313 0.04497967
## 54  2021-03-01  vxa 157489989 164644520  7154531 0.04441953
## 55  2021-03-02  vxa 160979444 168158060  7178616 0.04362077
## 56  2021-01-06  vxa  11649960  12161595   511635 0.04297367
## 57  2021-03-03  vxa 164872447 172091102  7218655 0.04284532
## 58  2021-03-04  vxa 169028852 176290956  7262104 0.04206016
## 59  2021-03-05  vxa 173999326 181305751  7306425 0.04112761
## 60  2021-01-05  vxa  10449850  10878916   429066 0.04023355
## 61  2021-03-06  vxa 179915926 187265421  7349495 0.04003196
## 62  2021-03-07  vxa 184896239 192285341  7389102 0.03918061
## 63  2021-03-08  vxa 188442277 195848093  7405816 0.03854281
## 64  2021-03-09  vxa 191740870 199160110  7419240 0.03795969
## 65  2021-03-10  vxa 195890209 203336007  7445798 0.03730115
## 66  2021-01-04  vxa   9775622  10140739   365117 0.03666503
## 67  2021-03-11  vxa 200963911 208437508  7473597 0.03650987
## 68  2021-03-12  vxa 206928026 214427848  7499822 0.03559852
## 69  2021-01-03  vxa   9296678   9627378   330700 0.03495022
## 70  2021-03-13  vxa 216273799 223812784  7538985 0.03426137
## 71  2021-03-14  vxa 219000382 226547859  7547477 0.03387951
## 72  2021-03-15  vxa 223169272 230728466  7559194 0.03330792
## 73  2021-03-16  vxa 226510722 234079842  7569120 0.03286702
## 74  2021-03-17  vxa 231194582 238780518  7585936 0.03228229
## 75  2021-03-18  vxa 236683177 244297330  7614153 0.03166096
## 76  2021-01-01  vxa   8345316   8611185   265869 0.03135895
## 77  2021-01-02  vxa   8926120   9208860   282740 0.03118173
## 78  2020-12-31  vxa   7476260   7712757   236497 0.03114053
## 79  2021-03-19  vxa 241951483 249582189  7630706 0.03104856
## 80  2021-03-20  vxa 248304380 255952591  7648211 0.03033458
## 81  2021-03-21  vxa 254494279 262157192  7662913 0.02966376
## 82  2021-03-22  vxa 258617091 266288288  7671197 0.02922888
## 83  2021-03-23  vxa 262046215 269722005  7675790 0.02886893
## 84  2021-03-24  vxa 266630324 274314227  7683903 0.02840921
## 85  2021-03-25  vxa 272372791 280063437  7690646 0.02784266
## 86  2021-03-26  vxa 279261974 286961402  7699428 0.02719573
## 87  2021-03-27  vxa 286363038 294070895  7707857 0.02655895
## 88  2020-12-30  vxa   6329704   6496853   167149 0.02606296
## 89  2021-03-28  vxa 293046372 300762295  7715923 0.02598791
## 90  2021-03-29  vxa 297812331 305530367  7718036 0.02558425
## 91  2021-03-30  vxa 301401971 309121935  7719964 0.02528964
## 92  2021-03-31  vxa 306831236 314557736  7726500 0.02486848
## 93  2021-04-01  vxa 313649661 321381014  7731353 0.02434954
## 94  2021-04-02  vxa 321693564 329428906  7735342 0.02376002
## 95  2021-04-03  vxa 329958345 337697137  7738792 0.02318199
## 96  2021-04-04  vxa 336791939 344534065  7742126 0.02272664
## 97  2021-04-05  vxa 341092155 348835528  7743373 0.02244691
## 98  2021-04-06  vxa 343928772 351677392  7748620 0.02227876
## 99  2021-04-07  vxa 349771863 357522867  7751004 0.02191732
## 100 2021-04-08  vxa 356650336 364404792  7754456 0.02150864
## 101 2021-04-09  vxa 364645110 372404496  7759386 0.02105526
## 102 2021-04-10  vxa 374016582 381780588  7764006 0.02054521
## 103 2021-04-11  vxa 381269358 389035360  7766002 0.02016345
## 104 2021-04-12  vxa 386616513 394383158  7766645 0.01988898
## 105 2021-04-13  vxa 391813947 399581255  7767308 0.01962940
## 106 2021-04-14  vxa 396910219 404680983  7770764 0.01938835
## 107 2021-04-15  vxa 404037086 411808985  7771899 0.01905237
## 108 2021-04-16  vxa 412044322 419819504  7775182 0.01869340
## 109 2020-12-29  vxa   5446606   5548984   102378 0.01862165
## 110 2021-04-17  vxa 419305065 427082242  7777177 0.01837735
## 111 2021-04-18  vxa 426459074 434238347  7779273 0.01807667
## 112 2021-04-19  vxa 430853470 438634220  7780750 0.01789732
## 113 2021-04-20  vxa 434474900 442255867  7780967 0.01774996
## 114 2021-04-21  vxa 439661586 447443801  7782215 0.01754519
## 115 2021-04-22  vxa 445719007 453502997  7783990 0.01731272
## 116 2021-04-23  vxa 452532096 460318300  7786204 0.01705910
## 117 2021-04-24  vxa 459239405 467028480  7789075 0.01681819
## 118 2021-04-25  vxa 465351768 473143258  7791490 0.01660422
## 119 2021-04-26  vxa 469586264 477377856  7791592 0.01645594
## 120 2021-04-27  vxa 472869743 480661468  7791725 0.01634288
## 121 2021-04-28  vxa 477382947 485175761  7792814 0.01619187
## 122 2021-04-29  vxa 482880799 490676060  7795261 0.01601398
## 123 2021-04-30  vxa 488529503 496326898  7797395 0.01583458
## 124 2021-05-01  vxa 495180084 502980017  7799933 0.01562862
## 125 2021-05-02  vxa 499489412 507291071  7801659 0.01549823
## 126 2021-05-03  vxa 501898168 509700681  7802513 0.01542610
## 127 2021-05-04  vxa 503882036 511684721  7802685 0.01536617
## 128 2021-05-05  vxa 507513496 515317513  7804017 0.01525964
## 129 2021-05-06  vxa 512372989 520178645  7805656 0.01511916
## 130 2021-05-07  vxa 518024858 525833299  7808441 0.01496073
## 131 2021-05-08  vxa 523201251 531012992  7811741 0.01482003
## 132 2021-05-09  vxa 527985953 535799586  7813633 0.01469024
## 133 2021-05-10  vxa 531759403 539573811  7814408 0.01458819
## 134 2021-05-11  vxa 534834342 542649370  7815028 0.01450607
## 135 2021-05-12  vxa 537960795 545776624  7815829 0.01442384
## 136 2021-05-13  vxa 541855568 549673486  7817918 0.01432471
## 137 2021-05-14  vxa 545571636 553393155  7821519 0.01423434
## 138 2021-05-15  vxa 550398046 558222357  7824311 0.01411540
## 139 2021-05-16  vxa 554623659 562449840  7826181 0.01401194
## 140 2021-05-17  vxa 557607976 565435800  7827824 0.01394037
## 141 2021-05-18  vxa 559857841 567685925  7828084 0.01388520
## 142 2020-12-28  vxa   4817252   4884299    67047 0.01382191
## 143 2021-05-19  vxa 563394524 571224729  7830205 0.01380235
## 144 2021-05-20  vxa 567647619 575479362  7831743 0.01370232
## 145 2021-05-21  vxa 572083034 579917747  7834713 0.01360192
## 146 2021-05-22  vxa 576809703 584647111  7837408 0.01349582
## 147 2021-05-23  vxa 580400750 588239955  7839205 0.01341594
## 148 2021-05-24  vxa 582749803 590589971  7840168 0.01336385
## 149 2021-05-25  vxa 584547054 592383117  7836063 0.01331611
## 150 2021-05-26  vxa 587421133 595259411  7838278 0.01325511
## 151 2020-12-27  vxa   4504812   4564760    59948 0.01321959
## 152 2021-05-27  vxa 590472787 598313357  7840570 0.01319088
## 153 2021-05-28  vxa 593258570 601101246  7842676 0.01313285
## 154 2021-05-29  vxa 596503808 604348968  7845160 0.01306598
## 155 2021-05-30  vxa 598969041 606816105  7847064 0.01301569
## 156 2021-05-31  vxa 600896395 608744277  7847882 0.01297556
## 157 2021-06-01  vxa 601923654 609771995  7848341 0.01295431
## 158 2021-06-02  vxa 602942370 610790920  7848550 0.01293291
## 159 2021-06-03  vxa 604585211 612434670  7849459 0.01289948
## 160 2020-12-24  vxa   3395582   3439504    43922 0.01285192
## 161 2021-06-04  vxa 607408409 615258306  7849897 0.01284062
## 162 2021-06-05  vxa 609728428 617580696  7852268 0.01279591
## 163 2021-06-06  vxa 612202377 620057995  7855618 0.01274993
## 164 2021-06-07  vxa 614926685 622782869  7856184 0.01269471
## 165 2021-06-08  vxa 617073291 624929490  7856199 0.01265086
## 166 2021-06-09  vxa 618754682 626611258  7856576 0.01261730
## 167 2021-06-10  vxa 620644278 628501824  7857546 0.01258067
## 168 2021-06-11  vxa 622290256 630149528  7859272 0.01255034
## 169 2021-06-12  vxa 625518205 633379718  7861513 0.01248952
## 170 2021-06-13  vxa 627960480 635824147  7863667 0.01244463
## 171 2021-06-14  vxa 630626715 638491078  7864363 0.01239343
## 172 2021-06-15  vxa 633115319 640981695  7866376 0.01234816
## 173 2021-06-16  vxa 635177490 643043939  7866449 0.01230843
## 174 2021-06-17  vxa 639314129 647184023  7869894 0.01223460
## 175 2021-06-18  vxa 641491889 649363524  7871635 0.01219600
## 176 2021-06-19  vxa 643648821 651522305  7873484 0.01215821
## 177 2021-06-20  vxa 645359689 653233746  7874057 0.01212705
## 178 2021-06-21  vxa 646592551 654472673  7880122 0.01211334
## 179 2021-06-22  vxa 647888063 655768668  7880605 0.01209000
## 180 2021-06-23  vxa 649193960 657076451  7882491 0.01206870
## 181 2021-06-24  vxa 650844276 658728749  7884473 0.01204129
## 182 2021-06-25  vxa 651883171 659768925  7885754 0.01202415
## 183 2021-06-26  vxa 653746142 661633477  7887335 0.01199248
## 184 2021-06-27  vxa 656160404 664049390  7888986 0.01195111
## 185 2021-06-28  vxa 658383276 666272326  7889050 0.01191110
## 186 2021-06-29  vxa 659901032 667790635  7889603 0.01188469
## 187 2020-12-26  vxa   4380828   4433001    52173 0.01183890
## 188 2021-06-30  vxa 662676560 670567209  7890649 0.01183677
## 189 2021-07-01  vxa 665963644 673855029  7891385 0.01177978
## 190 2021-07-02  vxa 667291980 675184975  7892995 0.01175885
## 191 2020-12-25  vxa   4067872   4115853    47981 0.01172596
## 192 2021-07-03  vxa 669628324 677521708  7893384 0.01171864
## 193 2021-07-04  vxa 670929526 678824343  7894817 0.01169816
## 194 2021-07-05  vxa 671735164 679630015  7894851 0.01168426
## 195 2021-07-06  vxa 672199146 680094016  7894870 0.01167627
## 196 2021-07-07  vxa 673074052 680969411  7895359 0.01166190
## 197 2021-07-08  vxa 674475410 682372114  7896704 0.01163978
## 198 2021-07-09  vxa 675728954 683626952  7897998 0.01162021
## 199 2021-07-10  vxa 676937142 684836241  7899099 0.01160119
## 200 2021-07-11  vxa 678122716 686022381  7899665 0.01158185
## 201 2021-07-12  vxa 679023069 686923718  7900649 0.01156802
## 202 2021-07-13  vxa 679708908 687610091  7901183 0.01155719
## 203 2021-07-14  vxa 680809727 688711439  7901712 0.01153938
## 204 2021-07-15  vxa 681954772 689857403  7902631 0.01152145
## 205 2021-07-16  vxa 683076155 690979758  7903603 0.01150405
## 206 2021-07-17  vxa 684358433 692262907  7904474 0.01148388
## 207 2021-07-18  vxa 685371906 693277651  7905745 0.01146882
## 208 2021-07-19  vxa 686388090 694294317  7906227 0.01145264
## 209 2021-07-20  vxa 686759099 694665840  7906741 0.01144722
## 210 2021-07-21  vxa 688016571 695924500  7907929 0.01142813
## 211 2021-07-22  vxa 689350784 697259348  7908564 0.01140705
## 212 2021-07-23  vxa 690563454 698458911  7895457 0.01136837
## 213 2021-07-24  vxa 691926058 699823425  7897367 0.01134883
## 214 2021-07-25  vxa 693498090 701397151  7899061 0.01132567
## 215 2021-07-26  vxa 694285530 702184652  7899122 0.01131298
## 216 2021-07-27  vxa 695077881 702977705  7899824 0.01130116
## 217 2021-07-28  vxa 696593467 704494043  7900576 0.01127778
## 218 2021-07-29  vxa 698030758 705932348  7901590 0.01125612
## 219 2021-07-30  vxa 699757751 707660172  7902421 0.01122967
## 220 2021-07-31  vxa 701197062 709100426  7903364 0.01120808
## 221 2021-08-01  vxa 702844466 710748186  7903720 0.01118246
## 222 2021-08-02  vxa 703782987 711687872  7904885 0.01116927
## 223 2021-08-03  vxa 704690674 712596258  7905584 0.01115594
## 224 2021-08-04  vxa 706154074 714060713  7906639 0.01113443
## 225 2021-08-05  vxa 707898247 715805607  7907360 0.01110815
## 226 2021-08-06  vxa 709556535 717464760  7908225 0.01108354
## 227 2021-08-07  vxa 711249564 719158886  7909322 0.01105883
## 228 2021-08-08  vxa 712811659 720722021  7910362 0.01103617
## 229 2021-08-09  vxa 713878648 721789066  7910418 0.01101985
## 230 2021-08-10  vxa 715115736 723026669  7910933 0.01100160
## 231 2021-08-11  vxa 716438666 724350295  7911629 0.01098236
## 232 2021-08-12  vxa 717763984 725676500  7912516 0.01096341
## 233 2021-08-13  vxa 719616893 727530633  7913740 0.01093702
## 234 2021-08-14  vxa 721621667 729536564  7914897 0.01090839
## 235 2021-08-15  vxa 722964598 730880861  7916263 0.01089010
## 236 2021-08-16  vxa 724687252 732604643  7917391 0.01086590
## 237 2021-08-17  vxa 725894030 733812644  7918614 0.01084960
## 238 2021-08-18  vxa 727318151 735237507  7919356 0.01082948
## 239 2021-08-19  vxa 729380316 737300431  7920115 0.01080005
## 240 2021-08-20  vxa 731420314 739341628  7921314 0.01077171
## 241 2021-08-21  vxa 733537317 741460274  7922957 0.01074301
## 242 2021-08-22  vxa 735499881 743423328  7923447 0.01071516
## 243 2021-08-23  vxa 736729701 744653478  7923777 0.01069781
## 244 2021-08-24  vxa 738031476 745957425  7925949 0.01068195
## 245 2021-08-25  vxa 739911752 747838251  7926499 0.01065569
## 246 2021-08-26  vxa 741787924 749715346  7927422 0.01063011
## 247 2021-08-27  vxa 743959352 751887925  7928573 0.01060078
## 248 2021-08-28  vxa 746134440 754064442  7930002 0.01057193
## 249 2021-08-29  vxa 748071410 756002444  7931034 0.01054607
## 250 2021-08-30  vxa 749467709 757399811  7932102 0.01052794
## 251 2021-08-31  vxa 750785914 758719509  7933595 0.01051152
## 252 2021-09-01  vxa 752949263 760883856  7934593 0.01048278
## 253 2021-09-02  vxa 754649632 762585018  7935386 0.01046033
## 254 2021-09-03  vxa 757482897 765421059  7938162 0.01042503
## 255 2021-09-04  vxa 759467604 767406259  7938655 0.01039857
## 256 2021-09-05  vxa 760691321 768630055  7938734 0.01038203
## 257 2021-09-06  vxa 761511343 769450114  7938771 0.01037096
## 258 2021-09-07  vxa 762523380 770463185  7939805 0.01035861
## 259 2021-09-08  vxa 764454842 772397079  7942237 0.01033572
## 260 2021-09-09  vxa 765824157 773767414  7943257 0.01031865
## 261 2021-09-10  vxa 767758097 775703164  7945067 0.01029513
## 262 2021-09-11  vxa 769603644 777550536  7946892 0.01027292
## 263 2021-09-12  vxa 771183033 779129925  7946892 0.01025198
## 264 2021-09-13  vxa 772373795 780320687  7946892 0.01023626
## 265 2021-09-14  vxa 773630897 781579289  7948392 0.01022163
## 266 2021-09-15  vxa 775340908 783289914  7949006 0.01019999
## 267 2021-09-16  vxa 776856560 784806820  7950260 0.01018178
## 268 2021-09-17  vxa 778796072 786748835  7952763 0.01015974
## 269 2021-09-18  vxa 780656201 788610284  7954083 0.01013733
## 270 2021-09-19  vxa 782031409 789985492  7954083 0.01011959
## 271 2021-09-20  vxa 783344685 791298768  7954083 0.01010271
## 272 2021-09-21  vxa 784436200 792392616  7956416 0.01009167
## 273 2021-09-22  vxa 785887057 793844457  7957400 0.01007437
## 274 2021-09-23  vxa 786571141 794530252  7959111 0.01006781
## 275 2021-09-24  vxa 788090243 796051559  7961316 0.01005127
## 276 2021-09-25  vxa 789734467 797697345  7962878 0.01003240
## 277 2021-09-26  vxa 791247931 799210809  7962878 0.01001331
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 20,127
## Columns: 69
## $ date                                   <date> 2021-10-24, 2021-10-24, 2021-1~
## $ MMWR_week                              <dbl> 43, 43, 43, 43, 43, 43, 43, 43,~
## $ state                                  <chr> "CT", "MD", "MH", "AK", "KS", "~
## $ Distributed                            <dbl> 5979725, 10599110, 57140, 11306~
## $ Distributed_Janssen                    <dbl> 280200, 479400, 11300, 72400, 2~
## $ Distributed_Moderna                    <dbl> 2367920, 3951380, 43500, 444260~
## $ Distributed_Pfizer                     <dbl> 3331605, 6168330, 2340, 613965,~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 167721, 175317, 97821, 154553, ~
## $ Distributed_Per_100k_12Plus            <dbl> 192525, 205294, 114546, 185690,~
## $ Distributed_Per_100k_18Plus            <dbl> 210713, 224987, 125591, 204986,~
## $ Distributed_Per_100k_65Plus            <dbl> 948795, 1104770, 577347, 123447~
## $ vxa                                    <dbl> 5288142, 8379027, 42025, 854656~
## $ Administered_12Plus                    <dbl> 5286342, 8378384, 41989, 852408~
## $ Administered_18Plus                    <dbl> 4892169, 7741330, 41224, 793669~
## $ Administered_65Plus                    <dbl> 1362943, 1942596, 2381, 169707,~
## $ Administered_Janssen                   <dbl> 209574, 303391, 2162, 35983, 11~
## $ Administered_Moderna                   <dbl> 1895023, 3022877, 39107, 324896~
## $ Administered_Pfizer                    <dbl> 3182162, 5040646, 754, 493195, ~
## $ Administered_Unk_Manuf                 <dbl> 1383, 12113, 2, 582, 1594, 371,~
## $ Admin_Per_100k                         <dbl> 148323, 138595, 71945, 116829, ~
## $ Admin_Per_100k_12Plus                  <dbl> 170201, 162281, 84173, 139997, ~
## $ Admin_Per_100k_18Plus                  <dbl> 172390, 164325, 90608, 143895, ~
## $ Admin_Per_100k_65Plus                  <dbl> 216256, 202481, 24058, 185294, ~
## $ Recip_Administered                     <dbl> 5297329, 8439877, 42077, 849994~
## $ Administered_Dose1_Recip               <dbl> 2789952, 4383458, 23753, 431503~
## $ Administered_Dose1_Pop_Pct             <dbl> 78.3, 72.5, 40.7, 59.0, 61.9, 7~
## $ Administered_Dose1_Recip_12Plus        <dbl> 2788575, 4382805, 23727, 430148~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 89.8, 84.9, 47.6, 70.6, 73.5, 8~
## $ Administered_Dose1_Recip_18Plus        <dbl> 2579599, 4045674, 23074, 399043~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 90.9, 85.9, 50.7, 72.3, 75.8, 8~
## $ Administered_Dose1_Recip_65Plus        <dbl> 650501, 940087, 1322, 80686, 48~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 99.9, 98.0, 13.4, 88.1, 99.9, 9~
## $ vxc                                    <dbl> 2506925, 3978145, 20218, 382736~
## $ vxcpoppct                              <dbl> 70.3, 65.8, 34.6, 52.3, 52.9, 6~
## $ Series_Complete_12Plus                 <dbl> 2506422, 3977925, 20207, 381864~
## $ Series_Complete_12PlusPop_Pct          <dbl> 80.7, 77.0, 40.5, 62.7, 62.8, 7~
## $ vxcgte18                               <dbl> 2325581, 3682392, 20177, 355192~
## $ vxcgte18pct                            <dbl> 81.9, 78.2, 44.3, 64.4, 64.9, 7~
## $ vxcgte65                               <dbl> 586541, 877275, 1151, 75064, 40~
## $ vxcgte65pct                            <dbl> 93.1, 91.4, 11.6, 82.0, 85.8, 8~
## $ Series_Complete_Janssen                <dbl> 208902, 297899, 2153, 33632, 10~
## $ Series_Complete_Moderna                <dbl> 889665, 1406414, 18049, 144516,~
## $ Series_Complete_Pfizer                 <dbl> 1407945, 2270604, 15, 204516, 8~
## $ Series_Complete_Unk_Manuf              <dbl> 413, 3228, 1, 72, 496, 189, 0, ~
## $ Series_Complete_Janssen_12Plus         <dbl> 208821, 297863, 2150, 33630, 10~
## $ Series_Complete_Moderna_12Plus         <dbl> 889434, 1406376, 18041, 144512,~
## $ Series_Complete_Pfizer_12Plus          <dbl> 1407758, 2270461, 15, 203650, 8~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 409, 3225, 1, 72, 496, 189, 0, ~
## $ Series_Complete_Janssen_18Plus         <dbl> 208725, 297692, 2144, 33495, 10~
## $ Series_Complete_Moderna_18Plus         <dbl> 889245, 1405935, 18019, 144126,~
## $ Series_Complete_Pfizer_18Plus          <dbl> 1227300, 1975672, 13, 177504, 7~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 311, 3093, 1, 67, 434, 174, 0, ~
## $ Series_Complete_Janssen_65Plus         <dbl> 20878, 53323, 100, 3222, 17510,~
## $ Series_Complete_Moderna_65Plus         <dbl> 231034, 414820, 1051, 41535, 19~
## $ Series_Complete_Pfizer_65Plus          <dbl> 335708, 410484, 0, 30491, 19690~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 88, 853, 0, 29, 222, 53, 0, 1, ~
## $ Additional_Doses                       <dbl> 171833, 285361, 9, 41549, 10797~
## $ Additional_Doses_Vax_Pct               <dbl> 6.9, 7.2, 0.0, 10.9, 7.0, 6.6, ~
## $ Additional_Doses_18Plus                <dbl> 171636, 284802, 9, 41381, 10773~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 7.4, 7.7, 0.0, 11.7, 7.5, 7.1, ~
## $ Additional_Doses_50Plus                <dbl> 155532, 232981, 3, 29298, 90319~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 26.5, 26.6, 0.3, 39.0, 22.1, 24~
## $ Additional_Doses_65Plus                <dbl> 129481, 173565, 0, 17552, 71028~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 22.1, 19.8, 0.0, 23.4, 17.4, 17~
## $ Additional_Doses_Moderna               <dbl> 14201, 48318, 7, 7372, 14412, 7~
## $ Additional_Doses_Pfizer                <dbl> 157304, 236541, 2, 34132, 93452~
## $ Additional_Doses_Janssen               <dbl> 108, 435, 0, 38, 70, 428, 8, 36~
## $ Additional_Doses_Unk_Manuf             <dbl> 220, 67, 0, 7, 38, 3, 20, 14, 0~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.16e+10    2.21e+8   4.52e+7 723299       37760    
## 2 after   1.16e+10    2.20e+8   4.50e+7 719774       32640    
## 3 pctchg  4.34e- 3    4.25e-3   4.62e-3      0.00487     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 32,640
## Columns: 6
## $ date       <date> 2021-09-01, 2021-01-13, 2020-07-30, 2021-02-02, 2020-05-03~
## $ state      <chr> "ND", "IN", "ME", "MS", "NH", "NV", "NE", "NC", "MI", "CT",~
## $ tot_cases  <dbl> 118491, 574488, 3910, 280182, 2518, 320719, 20150, 875359, ~
## $ tot_deaths <dbl> 1562, 10920, 123, 6730, 86, 5530, 282, 12363, 0, 3285, 4806~
## $ new_cases  <dbl> 536, 3654, 22, 1059, 89, 180, 179, 1614, 0, 621, 2750, 1446~
## $ new_deaths <dbl> 1, 74, 2, 13, 2, 0, -1, 16, 0, 66, 40, 33, 0, 16, 15, 162, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.48e+7    2.87e+7 634013      32249     
## 2 after  3.46e+7    2.86e+7 620096      31014     
## 3 pctchg 5.25e-3    5.12e-3      0.0220     0.0383
## 
## 
## Processed for cdcHosp:
## Rows: 31,014
## Columns: 5
## $ date       <date> 2020-10-13, 2020-10-12, 2020-10-11, 2020-10-11, 2020-10-10~
## $ state      <chr> "NH", "NH", "HI", "NM", "HI", "HI", "MD", "NC", "ID", "ND",~
## $ inp        <dbl> 34, 32, 99, 171, 127, 110, 756, 1427, 191, 194, 168, 91, 47~
## $ hosp_adult <dbl> 34, 31, 99, 166, 125, 108, 721, 1392, 189, 190, 166, 90, 47~
## $ hosp_ped   <dbl> 0, 1, 0, 5, 2, 2, 9, 35, 2, 4, 2, 1, 0, 1, 1, 9, 11, 3, 6, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65 vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>       <dbl>    <dbl>       <dbl>
## 1 before 1.46e+11 6.44e+10 573778.    1.88e+10 958324.     6.16e+10  697087.   
## 2 after  7.06e+10 3.11e+10 483274.    9.10e+ 9 870801.     2.98e+10  595268.   
## 3 pctchg 5.16e- 1 5.16e- 1      0.158 5.16e- 1      0.0913 5.17e- 1       0.146
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 16,065
## Columns: 9
## $ date        <date> 2021-10-24, 2021-10-24, 2021-10-24, 2021-10-24, 2021-10-2~
## $ state       <chr> "CT", "MD", "AK", "KS", "NJ", "NV", "NE", "HI", "KY", "PA"~
## $ vxa         <dbl> 5288142, 8379027, 854656, 3270476, 12082885, 3573760, 2287~
## $ vxc         <dbl> 2506925, 3978145, 382736, 1539866, 5861950, 1617387, 10822~
## $ vxcpoppct   <dbl> 70.3, 65.8, 52.3, 52.9, 66.0, 52.5, 55.9, 59.5, 54.5, 60.1~
## $ vxcgte65    <dbl> 586541, 877275, 75064, 407923, 1290147, 390112, 277232, 23~
## $ vxcgte65pct <dbl> 93.1, 91.4, 82.0, 85.8, 87.4, 78.7, 88.7, 87.2, 85.2, 90.1~
## $ vxcgte18    <dbl> 2325581, 3682392, 355192, 1436087, 5448479, 1521578, 10084~
## $ vxcgte18pct <dbl> 81.9, 78.2, 64.4, 64.9, 78.5, 63.7, 69.2, 71.0, 66.2, 71.4~
## 
## Integrated per capita data file:
## Rows: 32,904
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_211024, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_211024.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The post-processing steps are then run;

# Create pivoted burden data
burdenPivotList_211024 <- postProcessCDCDaily(cdc_daily_211024, 
                                              dataThruLabel="Oct 23, 2021", 
                                              keyDatesBurden=c("2021-10-23", "2021-04-23", 
                                                               "2020-10-23", "2020-04-23"
                                                               ),
                                              keyDatesVaccine=c("2021-10-23", "2021-08-23", 
                                                                "2021-06-23", "2021-04-23"
                                                                ), 
                                              returnData=TRUE
                                              )
## Joining, by = "state"
## 
## *** File has been checked for uniqueness by: state date name
## Warning: Removed 24 row(s) containing missing values (geom_path).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 24 rows containing missing values (position_stack).

## Warning: Removed 9 row(s) containing missing values (geom_path).

## Warning: Removed 51 rows containing missing values (geom_col).
## Warning: Removed 51 rows containing missing values (geom_text).
## Warning: Removed 51 rows containing missing values (geom_col).
## Warning: Removed 51 rows containing missing values (geom_text).

# Create hospitalized per capita data
hospAgePerCapita(dfStateAgeBucket, 
                 lst=burdenPivotList_211024, 
                 popVar="pop2019", 
                 excludeState=c("ND"), 
                 cumStartDate="2020-07-15"
                 )
## Warning: Removed 18 row(s) containing missing values (geom_path).

## # A tibble: 71,591 x 8
##    state date       bucket03 value     pop    vpm  vpm7 vpmcum
##    <chr> <date>     <chr>    <dbl>   <dbl>  <dbl> <dbl>  <dbl>
##  1 NV    2020-01-02 0-19         7  760090   9.21    NA   9.21
##  2 NV    2020-01-02 20-59       80 1627729  49.1     NA  49.1 
##  3 NV    2020-01-02 60+        156  681510 229.      NA 229.  
##  4 NV    2020-01-03 0-19         7  760090   9.21    NA  18.4 
##  5 NV    2020-01-03 20-59       80 1627729  49.1     NA  98.3 
##  6 NV    2020-01-03 60+        156  681510 229.      NA 458.  
##  7 AR    2020-01-04 0-19         0  778802   0       NA   0   
##  8 AR    2020-01-04 20-59        0 1521886   0       NA   0   
##  9 AR    2020-01-04 60+          0  711854   0       NA   0   
## 10 NV    2020-01-04 0-19         7  760090   9.21    NA  27.6 
## # ... with 71,581 more rows
# Create CFR plots for select states
cfrStates <- list("FL"=list(keyState="FL", minDate="2020-08-01", multDeath=70), 
                  "LA"=list(keyState="LA", minDate="2020-08-01", multDeath=80), 
                  "CA"=list(keyState="CA", minDate="2020-08-01", multDeath=100), 
                  "IL"=list(keyState="IL", minDate="2020-08-01", multDeath=100)
                  )
purrr::walk(cfrStates, .f=function(x) onePageCFRPlot(burdenPivotList_211024$dfPivot, 
                                                     keyState=x$keyState, 
                                                     minDate=x$minDate, 
                                                     multDeath=x$multDeath
                                                     )
            )

A function is written to find local peaks in a vector. Peaks are defined as local maxima for a given window:

# Function to find local extrema in a vector
findPeaks <- function(x, 
                      width=1, 
                      align="center", 
                      FUN=max, 
                      gt=if(identical(FUN, max)) 0 else NULL, 
                      lt=if(identical(FUN, min)) 0 else NULL, 
                      fillVal=if(identical(FUN, max)) gt else if(identical(FUN, min)) lt else NA, 
                      epsTol=1e-12,
                      returnBool=TRUE, 
                      ...
                      ) {
    
    # FUNCTION ARGUMENTS:
    # x: a numeric vector
    # width: the width of the window to use
    # align: whether the window should be "center", "left", or "right"
    # FUN: the function to be used (max to find peaks, min to find valleys)
    # gt: to be defined, the value must be greater than gt (NULL means use any value)
    # lt: to be defined, the value must be less than lt (NULL means use any value)
    # fillVal: value to use as output if a window does not exist (too close to boundary)
    # epsTol: the epsilon value for considering two values to be the same
    # returnBool: should the boolean be returned? TRUE means return TRUE/FALSE for peaks, FALSE means return vector
    # ...: any other arguments to be passed to zoo::rollapply()
    
    # Create the rolling data
    rolls <- zoo::rollapply(x, width=width, align=align, FUN=FUN, fill=fillVal, ...)
    
    # No post-processing applied unless returnBool is TRUE
    if(!isTRUE(returnBool)) return(rolls)
    
    # Post-processing managed for gt and lt
    if(!is.null(gt)) rolls <- ifelse(rolls<=gt, NA, rolls)
    if(!is.null(lt)) rolls <- ifelse(rolls>=lt, NA, rolls)
    
    # Return the boolean vector
    !is.na(rolls) & (abs(rolls-x) <= epsTol)
    
}

# Testing on a sinusoidal sequence
sinX <- seq(0, 10*pi, by=0.01*pi)
ggplot(tibble::tibble(x=sinX, y=sin(sinX)), aes(x=x, y=y)) + 
    geom_line() + 
    geom_point(data=~filter(tibble::tibble(x=sinX, y=sin(sinX), z=findPeaks(y, width=21)), z), 
               color="green", 
               size=5
               ) +
    geom_point(data=~filter(tibble::tibble(x=sinX, y=sin(sinX), z=findPeaks(y, width=21, FUN=min)), z), 
               color="red", 
               size=5
               ) +
    labs(x=NULL, 
         y=NULL, 
         title="Example of maxima and minima for a sin curve", 
         subtitle="Green (max) and Red (min)"
         )

# Testing on national deaths data
cdc_daily_211024$dfPerCapita %>%
    group_by(date) %>%
    summarize(deaths=sum(new_deaths, na.rm=TRUE), .groups="drop") %>%
    mutate(deaths7=zoo::rollmean(deaths, k=7, fill=NA), 
           isPeak=findPeaks(deaths7, width=29, gt=1), 
           isValley=findPeaks(deaths7, width=29, FUN=min, gt=1, lt=NULL, fillVal=NA)
           ) %>%
    ggplot(aes(x=date, y=deaths7)) + 
    geom_line() + 
    geom_point(data=~filter(., isPeak), color="red", size=3) +
    geom_text(data=~filter(., isPeak), aes(y=deaths7+100, label=date), color="red", size=3) + 
    geom_point(data=~filter(., isValley), color="green", size=3) + 
    geom_text(data=~filter(., isValley), aes(y=deaths7-100, label=date), color="black", size=3) + 
    labs(x=NULL, 
         y="Rolling 7-day mean deaths", 
         title="US COVID deaths peaks and valleys", 
         subtitle="Red (peaks) and green (valleys)"
         )
## Warning: Removed 6 row(s) containing missing values (geom_path).

The peaks can be calculated by census region with values for the peak and valley included:

cdc_daily_211024$dfPerCapita %>% 
    mutate(region=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    group_by(region, date) %>%
    summarize(deaths=sum(new_deaths, na.rm=TRUE), .groups="drop") %>% 
    group_by(region) %>%
    mutate(deaths7=zoo::rollmean(deaths, k=7, fill=NA), 
           isPeak=findPeaks(deaths7, width=71, gt=1), 
           isValley=findPeaks(deaths7, width=71, FUN=min, gt=1, lt=NULL, fillVal=NA)
    ) %>% 
    ungroup() %>%
    ggplot(aes(x=date, y=deaths7)) + 
    geom_line() + 
    geom_point(data=~filter(., isPeak), color="red", size=3) +
    geom_text(data=~filter(., isPeak), 
              aes(y=deaths7+100, label=paste0(date, "\n", round(deaths))), 
              color="red", 
              size=3
              ) + 
    geom_point(data=~filter(., isValley), color="green", size=3) + 
    geom_text(data=~filter(., isValley), 
              aes(y=deaths7-100, label=paste0(date, "\n", round(deaths))), 
              color="black", 
              size=3
              ) + 
    labs(x=NULL, 
         y="Rolling 7-day mean deaths", 
         title="US COVID deaths peaks and valleys", 
         subtitle="Red (peaks) and green (valleys)"
         ) + 
    facet_wrap(~region, scales="free_y")
## Warning: Removed 6 row(s) containing missing values (geom_path).

A similar approach can be run for states of at least 5 million people:

cdc_daily_211024$dfPerCapita %>% 
    filter(state %in% (getStateData() %>% filter(pop >= 5000000) %>% pull(state))) %>%
    group_by(state, date) %>%
    summarize(deaths=sum(new_deaths, na.rm=TRUE), .groups="drop") %>% 
    group_by(state) %>%
    mutate(deaths7=zoo::rollmean(deaths, k=7, fill=NA), 
           isPeak=findPeaks(deaths7, width=71, gt=1), 
           isValley=findPeaks(deaths7, width=71, FUN=min, gt=1, lt=NULL, fillVal=NA)
    ) %>% 
    ungroup() %>%
    ggplot(aes(x=date, y=deaths7)) + 
    geom_line() + 
    geom_point(data=~filter(., isPeak), color="red", size=3) +
    geom_text(data=~filter(., isPeak), 
              aes(y=deaths7+100, label=paste0(date, "\n", round(deaths))), 
              color="red", 
              size=3
              ) + 
    geom_point(data=~filter(., isValley), color="green", size=3) + 
    geom_text(data=~filter(., isValley), 
              aes(y=deaths7-100, label=paste0(date, "\n", round(deaths))), 
              color="black", 
              size=3
              ) + 
    labs(x=NULL, 
         y="Rolling 7-day mean deaths", 
         title="US COVID deaths peaks and valleys", 
         subtitle="Red (peaks) and green (valleys)"
         ) + 
    facet_wrap(~state, scales="free_y")
## Warning: Removed 6 row(s) containing missing values (geom_path).

There is some noise to the state-level data, but the approach is generally identifying the right peaks and valleys. Next steps are to add post-processing so that certain peaks and valleys (such as a repeating value) are filtered. The approach is applied to US hospitalizations data:

cdc_daily_211024$dfPerCapita %>% 
    group_by(date) %>%
    summarize(hosp=sum(inp, na.rm=TRUE), .groups="drop") %>% 
    mutate(hosp7=zoo::rollmean(hosp, k=7, fill=NA), 
           isPeak=findPeaks(hosp7, width=71, gt=1), 
           isValley=findPeaks(hosp7, width=71, FUN=min, gt=1, lt=NULL, fillVal=NA)
    ) %>% 
    ungroup() %>%
    ggplot(aes(x=date, y=hosp7/1000)) + 
    geom_line() + 
    geom_point(data=~filter(., isPeak), color="red", size=3) +
    geom_text(data=~filter(., isPeak), 
              aes(y=hosp7/1000+10, label=paste0(date, "\n", round(hosp7/1000, 1))), 
              color="red", 
              size=3
              ) + 
    geom_point(data=~filter(., isValley), color="green", size=3) + 
    geom_text(data=~filter(., isValley), 
              aes(y=hosp7/1000-10, label=paste0(date, "\n", round(hosp7/1000, 1))), 
              color="black", 
              size=3
              ) + 
    labs(x=NULL, 
         y="Rolling 7-day mean hospitalized (000)", 
         title="US COVID hospitalized (000) peaks and valleys", 
         subtitle="Red (peaks) and green (valleys)"
         )
## Warning: Removed 6 row(s) containing missing values (geom_path).

A function is written to allow for different variables and facets to be used:

makePeakValley <- function(df, 
                           numVar, 
                           windowWidth,
                           rollMean=NULL, 
                           uqBy=c("date"), 
                           facetVar=c(), 
                           fnNumVar=function(x) x, 
                           fnPeak=function(x) x+100, 
                           fnValley=function(x) x-100, 
                           useTitle="", 
                           yLab=""
                           ) {
    
    # FUNCTION ARGUMENTS
    # df: a data frame or tibble
    # numVar: the numeric variable of interest
    # windowWidth: width of the window for calculating peaks and valleys
    # rollMean: the number of days for rolling mean (NULL means no rolling mean)
    # uqBy: variable that the resutling data should be unique by
    # facetVar: variable for faceting (c() means no facets)
    # fnNumVar: what function should be applied to numVar (e.g., function(x) x/1000)
    # fnPeak: function for plotting the peak labels
    # fnValley: function for plotting the valley labels
    # useTitle: title for plots
    # yLab: y-axis label for plots
    
    # Create named vectors for useTitle and yLab if not passed
    if(is.null(names(useTitle))) 
        useTitle <- rep(useTitle, times=length(numVar)) %>% purrr::set_names(all_of(numVar))
    if(is.null(names(yLab))) 
        yLab <- rep(yLab, times=length(numVar)) %>% purrr::set_names(all_of(numVar))
    
    # Create named lists for fnNumVar, fnPeak, and fnValley
    tempMakeList <- function(f, n, nms) {
        tempList <- vector("list", length=n)
        for(a in 1:n) tempList[[a]] <- f
        names(tempList) <- nms
        tempList
    }
    if(is.null(names(fnNumVar))) fnNumVar <- tempMakeList(fnNumVar, n=length(numVar), nms=numVar)
    if(is.null(names(fnPeak))) fnPeak <- tempMakeList(fnPeak, n=length(numVar), nms=numVar)
    if(is.null(names(fnValley))) fnValley <- tempMakeList(fnValley, n=length(numVar), nms=numVar)
    
    # Create the relevant data frame
    newDF <- df %>% 
        group_by_at(all_of(c(uqBy, facetVar))) %>%
        summarize(across(all_of(numVar), .fns=sum, na.rm=TRUE), .groups="drop") %>%
        group_by_at(all_of(facetVar)) %>%
        mutate(if(!is.null(rollMean)) across(all_of(numVar), .fns=zoo::rollmean, k=rollMean, fill=NA),
               across(all_of(numVar), .fns=findPeaks, width=windowWidth, gt=1, .names="{.col}_isPeak"),
               across(all_of(numVar), 
                      .fns=findPeaks, 
                      width=windowWidth, 
                      FUN=min, 
                      gt=1, 
                      lt=NULL, 
                      fillVal=NA 
                      ,.names="{.col}_isValley"
                      )
               ) %>% 
        ungroup()
    
    # Create the relevant plots
    for(keyVar in numVar) {
    
        p1 <- newDF %>%
            ggplot(aes(x=get(uqBy), y=fnNumVar[[keyVar]](get(keyVar)))) + 
            geom_line() + 
            geom_point(data=~filter(., get(paste0(keyVar, "_isPeak"))), color="red", size=3) +
            geom_point(data=~filter(., get(paste0(keyVar, "_isValley"))), color="green", size=3) + 
            geom_text(data=~filter(., get(paste0(keyVar, "_isPeak"))), 
                      aes(y=fnPeak[[keyVar]](fnNumVar[[keyVar]](get(keyVar))), 
                          label=paste0(get(uqBy), "\n", round(fnNumVar[[keyVar]](get(keyVar))))
                          ), 
                      color="red", 
                      size=3
                      ) + 
            geom_text(data=~filter(., get(paste0(keyVar, "_isValley"))), 
                      aes(y=fnValley[[keyVar]](fnNumVar[[keyVar]](get(keyVar))), 
                          label=paste0(get(uqBy), "\n", round(fnNumVar[[keyVar]](get(keyVar))))
                          ), 
                      color="black", 
                      size=3
                      ) + 
            labs(x=NULL, 
                 y=yLab[[keyVar]], 
                 title=useTitle[[keyVar]], 
                 subtitle="Red (peaks) and green (valleys)"
                 )
        if(length(facetVar) > 0) p1 <- p1 + facet_wrap(~get(facetVar), scales="free_y")

        print(p1)
    
    }
    
    return(newDF)
    
}

cdc_daily_211024$dfPerCapita %>%
    mutate(regn=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    makePeakValley(numVar=c("new_deaths", "new_cases", "inp"), 
                   windowWidth = 71, 
                   rollMean=7, 
                   facetVar=c("regn"), 
                   fnNumVar=function(x) x/1000, 
                   useTitle=c("new_deaths"="US coronavirus deaths", 
                              "new_cases"="US coronavirus cases", 
                              "inp"="US coronavirus total hospitalized"
                              ), 
                   yLab=c("new_deaths"="Rolling 7-day mean deaths (000)", 
                          "new_cases"="Rolling 7-day mean cases (000)", 
                          "inp"="Rolling 7-day mean in hospital (000)"
                          )
                   )
## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## # A tibble: 2,631 x 11
##    date       regn  new_deaths new_cases   inp new_deaths_isPe~ new_cases_isPeak
##    <date>     <chr>      <dbl>     <dbl> <dbl> <lgl>            <lgl>           
##  1 2020-01-01 Nort~         NA        NA    NA FALSE            FALSE           
##  2 2020-01-01 South         NA        NA    NA FALSE            FALSE           
##  3 2020-01-01 West          NA        NA    NA FALSE            FALSE           
##  4 2020-01-02 Nort~         NA        NA    NA FALSE            FALSE           
##  5 2020-01-02 South         NA        NA    NA FALSE            FALSE           
##  6 2020-01-02 West          NA        NA    NA FALSE            FALSE           
##  7 2020-01-03 Nort~         NA        NA    NA FALSE            FALSE           
##  8 2020-01-03 South         NA        NA    NA FALSE            FALSE           
##  9 2020-01-03 West          NA        NA    NA FALSE            FALSE           
## 10 2020-01-04 Nort~          0         0     0 FALSE            FALSE           
## # ... with 2,621 more rows, and 4 more variables: inp_isPeak <lgl>,
## #   new_deaths_isValley <lgl>, new_cases_isValley <lgl>, inp_isValley <lgl>
cdc_daily_211024$dfPerCapita %>%
    mutate(regn=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    makePeakValley(numVar=c("new_deaths", "new_cases", "inp"), 
                   windowWidth = 71, 
                   rollMean=7, 
                   facetVar=c("regn"), 
                   fnNumVar=list("new_deaths"=function(x) x, 
                                 "new_cases"=function(x) x/1000,
                                 "inp"=function(x) x/1000
                                 ), 
                   fnPeak=list("new_deaths"=function(x) x+100, 
                               "new_cases"=function(x) x+10, 
                               "inp"=function(x) x+10
                               ),
                   fnValley=list("new_deaths"=function(x) x-100, 
                                 "new_cases"=function(x) x-5, 
                                 "inp"=function(x) x-5
                                 ),
                   useTitle=c("new_deaths"="US coronavirus deaths", 
                              "new_cases"="US coronavirus cases", 
                              "inp"="US coronavirus total hospitalized"
                              ), 
                   yLab=c("new_deaths"="Rolling 7-day mean deaths", 
                          "new_cases"="Rolling 7-day mean cases (000)", 
                          "inp"="Rolling 7-day mean in hospital (000)"
                          )
                   )
## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## # A tibble: 2,631 x 11
##    date       regn  new_deaths new_cases   inp new_deaths_isPe~ new_cases_isPeak
##    <date>     <chr>      <dbl>     <dbl> <dbl> <lgl>            <lgl>           
##  1 2020-01-01 Nort~         NA        NA    NA FALSE            FALSE           
##  2 2020-01-01 South         NA        NA    NA FALSE            FALSE           
##  3 2020-01-01 West          NA        NA    NA FALSE            FALSE           
##  4 2020-01-02 Nort~         NA        NA    NA FALSE            FALSE           
##  5 2020-01-02 South         NA        NA    NA FALSE            FALSE           
##  6 2020-01-02 West          NA        NA    NA FALSE            FALSE           
##  7 2020-01-03 Nort~         NA        NA    NA FALSE            FALSE           
##  8 2020-01-03 South         NA        NA    NA FALSE            FALSE           
##  9 2020-01-03 West          NA        NA    NA FALSE            FALSE           
## 10 2020-01-04 Nort~          0         0     0 FALSE            FALSE           
## # ... with 2,621 more rows, and 4 more variables: inp_isPeak <lgl>,
## #   new_deaths_isValley <lgl>, new_cases_isValley <lgl>, inp_isValley <lgl>

The same process is run with the vaccinations data:

cdc_daily_211024$dfPerCapita %>%
    select(date, state, vxa, vxc) %>%
    arrange(date, state) %>%
    group_by(state) %>%
    mutate(across(c(vxa, vxc), .fns=function(x) x-lag(x))) %>%
    ungroup() %>%
    mutate(regn=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    filter(date >= "2020-12-01") %>%
    makePeakValley(numVar=c("vxc", "vxa"), 
                   windowWidth = 29, 
                   rollMean=15, 
                   facetVar=c("regn"), 
                   fnNumVar=list("vxa"=function(x) x/1000, 
                                 "vxc"=function(x) x/1000
                                 ), 
                   fnPeak=list("vxa"=function(x) x+50, 
                               "vxc"=function(x) x+50
                               ),
                   fnValley=list("vxa"=function(x) x-50, 
                                 "vxc"=function(x) x-50
                                 ),
                   useTitle=c("vxa"="Vaccines adminsitered (US)", 
                              "vxc"="Became fully vaccinated (US)"
                              ), 
                   yLab=c("vxa"="Rolling 15-day mean administered (000)",
                          "vxc"="Rolling 15-day mean completed (000)"
                          )
                   )
## Warning: Removed 14 row(s) containing missing values (geom_path).

## Warning: Removed 14 row(s) containing missing values (geom_path).

## # A tibble: 1,312 x 8
##    date       regn     vxc   vxa vxc_isPeak vxa_isPeak vxc_isValley vxa_isValley
##    <date>     <chr>  <dbl> <dbl> <lgl>      <lgl>      <lgl>        <lgl>       
##  1 2020-12-01 North~    NA    NA FALSE      FALSE      FALSE        FALSE       
##  2 2020-12-01 North~    NA    NA FALSE      FALSE      FALSE        FALSE       
##  3 2020-12-01 South     NA    NA FALSE      FALSE      FALSE        FALSE       
##  4 2020-12-01 West      NA    NA FALSE      FALSE      FALSE        FALSE       
##  5 2020-12-02 North~    NA    NA FALSE      FALSE      FALSE        FALSE       
##  6 2020-12-02 North~    NA    NA FALSE      FALSE      FALSE        FALSE       
##  7 2020-12-02 South     NA    NA FALSE      FALSE      FALSE        FALSE       
##  8 2020-12-02 West      NA    NA FALSE      FALSE      FALSE        FALSE       
##  9 2020-12-03 North~    NA    NA FALSE      FALSE      FALSE        FALSE       
## 10 2020-12-03 North~    NA    NA FALSE      FALSE      FALSE        FALSE       
## # ... with 1,302 more rows

The process is repeated, focused only on states of at least 8 million people:

cdc_daily_211024$dfPerCapita %>%
    inner_join(getStateData(), by=c("state")) %>%
    filter(pop >= 8000000) %>%
    select(date, state, vxa, vxc) %>%
    arrange(date, state) %>%
    group_by(state) %>%
    mutate(across(c(vxa, vxc), .fns=function(x) x-lag(x))) %>%
    ungroup() %>%
    mutate(regn=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    filter(date >= "2020-12-01") %>%
    makePeakValley(numVar=c("vxc", "vxa"), 
                   windowWidth = 29, 
                   rollMean=21, 
                   facetVar=c("state"), 
                   fnNumVar=list("vxa"=function(x) x/1000, 
                                 "vxc"=function(x) x/1000
                                 ), 
                   fnPeak=list("vxa"=function(x) x+25, 
                               "vxc"=function(x) x+25
                               ),
                   fnValley=list("vxa"=function(x) x-25, 
                                 "vxc"=function(x) x-25
                                 ),
                   useTitle=c("vxa"="Vaccines adminsitered (US)", 
                              "vxc"="Became fully vaccinated (US)"
                              ), 
                   yLab=c("vxa"="Rolling 21-day mean administered (000)",
                          "vxc"="Rolling 21-day mean completed (000)"
                          )
                   )
## Warning: Removed 20 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## # A tibble: 3,936 x 8
##    date       state   vxc   vxa vxc_isPeak vxa_isPeak vxc_isValley vxa_isValley
##    <date>     <chr> <dbl> <dbl> <lgl>      <lgl>      <lgl>        <lgl>       
##  1 2020-12-01 CA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  2 2020-12-01 FL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  3 2020-12-01 GA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  4 2020-12-01 IL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  5 2020-12-01 MI       NA    NA FALSE      FALSE      FALSE        FALSE       
##  6 2020-12-01 NC       NA    NA FALSE      FALSE      FALSE        FALSE       
##  7 2020-12-01 NJ       NA    NA FALSE      FALSE      FALSE        FALSE       
##  8 2020-12-01 NY       NA    NA FALSE      FALSE      FALSE        FALSE       
##  9 2020-12-01 OH       NA    NA FALSE      FALSE      FALSE        FALSE       
## 10 2020-12-01 PA       NA    NA FALSE      FALSE      FALSE        FALSE       
## # ... with 3,926 more rows

Next steps are to allow for a custom function by facet, to allow for labels in different positions when facets have different ranges:

makePeakValley <- function(df, 
                           numVar, 
                           windowWidth,
                           rollMean=NULL, 
                           uqBy=c("date"), 
                           facetVar=c(), 
                           fnNumVar=function(x) x, 
                           fnPeak=function(x) x+100, 
                           fnValley=function(x) x-100, 
                           fnGroupFacet=FALSE,
                           useTitle="", 
                           yLab=""
                           ) {
    
    # FUNCTION ARGUMENTS
    # df: a data frame or tibble
    # numVar: the numeric variable of interest
    # windowWidth: width of the window for calculating peaks and valleys
    # rollMean: the number of days for rolling mean (NULL means no rolling mean)
    # uqBy: variable that the resutling data should be unique by
    # facetVar: variable for faceting (c() means no facets)
    # fnNumVar: what function should be applied to numVar (e.g., function(x) x/1000)
    # fnPeak: function for plotting the peak labels
    # fnValley: function for plotting the valley labels
    # fnGroupFacet: boolean, should the functions be run separatelt for each facet as a grouping variable?
    #               useful for labeling if the goal is to use 0.1*max(yVar) rather than a global peak and valley
    # useTitle: title for plots
    # yLab: y-axis label for plots
    
    # Create named vectors for useTitle and yLab if not passed
    if(is.null(names(useTitle))) 
        useTitle <- rep(useTitle, times=length(numVar)) %>% purrr::set_names(all_of(numVar))
    if(is.null(names(yLab))) 
        yLab <- rep(yLab, times=length(numVar)) %>% purrr::set_names(all_of(numVar))
    
    # Create named lists for fnNumVar, fnPeak, and fnValley
    tempMakeList <- function(f, n, nms) {
        tempList <- vector("list", length=n)
        for(a in 1:n) tempList[[a]] <- f
        names(tempList) <- nms
        tempList
    }
    if(is.null(names(fnNumVar))) fnNumVar <- tempMakeList(fnNumVar, n=length(numVar), nms=numVar)
    if(is.null(names(fnPeak))) fnPeak <- tempMakeList(fnPeak, n=length(numVar), nms=numVar)
    if(is.null(names(fnValley))) fnValley <- tempMakeList(fnValley, n=length(numVar), nms=numVar)
    
    # Create the relevant data frame
    newDF <- df %>% 
        group_by_at(all_of(c(uqBy, facetVar))) %>%
        summarize(across(all_of(numVar), .fns=sum, na.rm=TRUE), .groups="drop") %>%
        group_by_at(all_of(facetVar)) %>%
        mutate(if(!is.null(rollMean)) across(all_of(numVar), .fns=zoo::rollmean, k=rollMean, fill=NA),
               across(all_of(numVar), .fns=findPeaks, width=windowWidth, gt=1, .names="{.col}_isPeak"),
               across(all_of(numVar), 
                      .fns=findPeaks, 
                      width=windowWidth, 
                      FUN=min, 
                      gt=1, 
                      lt=NULL, 
                      fillVal=NA 
                      ,.names="{.col}_isValley"
                      )
               ) %>% 
        ungroup()

    # Group by the facet variable(s) if not NULL and separate function by facet requested
    if(!is.null(facetVar) & isTRUE(fnGroupFacet)) newDF <- newDF %>% group_by_at(all_of(facetVar))
    
    # Create the relevant plots
    for(keyVar in numVar) {
    
        p1 <- newDF %>%
            mutate(posPeak=fnPeak[[keyVar]](fnNumVar[[keyVar]](get(keyVar))), 
                   posValley=fnValley[[keyVar]](fnNumVar[[keyVar]](get(keyVar)))
                   ) %>%
            ggplot(aes(x=get(uqBy), y=fnNumVar[[keyVar]](get(keyVar)))) + 
            geom_line() + 
            geom_point(data=~filter(., get(paste0(keyVar, "_isPeak"))), color="red", size=3) +
            geom_point(data=~filter(., get(paste0(keyVar, "_isValley"))), color="green", size=3) + 
            geom_text(data=~filter(., get(paste0(keyVar, "_isPeak"))), 
                      aes(y=posPeak, 
                          label=paste0(get(uqBy), "\n", round(fnNumVar[[keyVar]](get(keyVar))))
                          ), 
                      color="red", 
                      size=3
                      ) + 
            geom_text(data=~filter(., get(paste0(keyVar, "_isValley"))), 
                      aes(y=posValley, 
                          label=paste0(get(uqBy), "\n", round(fnNumVar[[keyVar]](get(keyVar))))
                          ), 
                      color="black", 
                      size=3
                      ) + 
            labs(x=NULL, 
                 y=yLab[[keyVar]], 
                 title=useTitle[[keyVar]], 
                 subtitle="Red (peaks) and green (valleys)"
                 )
        if(length(facetVar) > 0) p1 <- p1 + facet_wrap(~get(facetVar), scales="free_y")

        print(p1)
    
    }
    
    # Return the data, removing any grouping
    newDF %>% ungroup()
    
}


# Original format for burden
cdc_daily_211024$dfPerCapita %>%
    mutate(regn=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    makePeakValley(numVar=c("new_deaths", "new_cases", "inp"), 
                   windowWidth = 71, 
                   rollMean=7, 
                   facetVar=c("regn"), 
                   fnNumVar=list("new_deaths"=function(x) x, 
                                 "new_cases"=function(x) x/1000,
                                 "inp"=function(x) x/1000
                                 ), 
                   fnPeak=list("new_deaths"=function(x) x+100, 
                               "new_cases"=function(x) x+10, 
                               "inp"=function(x) x+10
                               ),
                   fnValley=list("new_deaths"=function(x) x-100, 
                                 "new_cases"=function(x) x-5, 
                                 "inp"=function(x) x-5
                                 ),
                   useTitle=c("new_deaths"="US coronavirus deaths", 
                              "new_cases"="US coronavirus cases", 
                              "inp"="US coronavirus total hospitalized"
                              ), 
                   yLab=c("new_deaths"="Rolling 7-day mean deaths", 
                          "new_cases"="Rolling 7-day mean cases (000)", 
                          "inp"="Rolling 7-day mean in hospital (000)"
                          )
                   )
## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## Warning: Removed 6 row(s) containing missing values (geom_path).

## # A tibble: 2,631 x 11
##    date       regn  new_deaths new_cases   inp new_deaths_isPe~ new_cases_isPeak
##    <date>     <chr>      <dbl>     <dbl> <dbl> <lgl>            <lgl>           
##  1 2020-01-01 Nort~         NA        NA    NA FALSE            FALSE           
##  2 2020-01-01 South         NA        NA    NA FALSE            FALSE           
##  3 2020-01-01 West          NA        NA    NA FALSE            FALSE           
##  4 2020-01-02 Nort~         NA        NA    NA FALSE            FALSE           
##  5 2020-01-02 South         NA        NA    NA FALSE            FALSE           
##  6 2020-01-02 West          NA        NA    NA FALSE            FALSE           
##  7 2020-01-03 Nort~         NA        NA    NA FALSE            FALSE           
##  8 2020-01-03 South         NA        NA    NA FALSE            FALSE           
##  9 2020-01-03 West          NA        NA    NA FALSE            FALSE           
## 10 2020-01-04 Nort~          0         0     0 FALSE            FALSE           
## # ... with 2,621 more rows, and 4 more variables: inp_isPeak <lgl>,
## #   new_deaths_isValley <lgl>, new_cases_isValley <lgl>, inp_isValley <lgl>
# Modified format - vaccinations by state
cdc_daily_211024$dfPerCapita %>%
    inner_join(getStateData(), by=c("state")) %>%
    filter(pop >= 8000000) %>%
    select(date, state, vxa, vxc) %>%
    arrange(date, state) %>%
    group_by(state) %>%
    mutate(across(c(vxa, vxc), .fns=function(x) x-lag(x))) %>%
    ungroup() %>%
    mutate(regn=c(as.character(state.region), "South")[match(state, c(state.abb, "DC"))]) %>%
    filter(date >= "2020-12-01") %>%
    makePeakValley(numVar=c("vxc", "vxa"), 
                   windowWidth = 29, 
                   rollMean=21, 
                   facetVar=c("state"), 
                   fnNumVar=list("vxa"=function(x) x/1000, 
                                 "vxc"=function(x) x/1000
                                 ), 
                   fnPeak=list("vxa"=function(x) x+25*max(x, na.rm=TRUE)/400, 
                               "vxc"=function(x) x+25*max(x, na.rm=TRUE)/400
                               ),
                   fnValley=list("vxa"=function(x) x-25*max(x, na.rm=TRUE)/400, 
                                 "vxc"=function(x) x-25*max(x, na.rm=TRUE)/400
                                 ),
                   fnGroupFacet=TRUE,
                   useTitle=c("vxa"="Vaccines adminsitered (US)", 
                              "vxc"="Became fully vaccinated (US)"
                              ), 
                   yLab=c("vxa"="Rolling 21-day mean administered (000)",
                          "vxc"="Rolling 21-day mean completed (000)"
                          )
                   )
## Warning: Removed 20 row(s) containing missing values (geom_path).

## Warning: Removed 20 row(s) containing missing values (geom_path).

## # A tibble: 3,936 x 8
##    date       state   vxc   vxa vxc_isPeak vxa_isPeak vxc_isValley vxa_isValley
##    <date>     <chr> <dbl> <dbl> <lgl>      <lgl>      <lgl>        <lgl>       
##  1 2020-12-01 CA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  2 2020-12-01 FL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  3 2020-12-01 GA       NA    NA FALSE      FALSE      FALSE        FALSE       
##  4 2020-12-01 IL       NA    NA FALSE      FALSE      FALSE        FALSE       
##  5 2020-12-01 MI       NA    NA FALSE      FALSE      FALSE        FALSE       
##  6 2020-12-01 NC       NA    NA FALSE      FALSE      FALSE        FALSE       
##  7 2020-12-01 NJ       NA    NA FALSE      FALSE      FALSE        FALSE       
##  8 2020-12-01 NY       NA    NA FALSE      FALSE      FALSE        FALSE       
##  9 2020-12-01 OH       NA    NA FALSE      FALSE      FALSE        FALSE       
## 10 2020-12-01 PA       NA    NA FALSE      FALSE      FALSE        FALSE       
## # ... with 3,926 more rows

The latest data are downloaded and processed:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_211104.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_211104.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_211104.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_211006")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_211006")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_211006")$dfRaw$vax
                    )

cdc_daily_211104 <- readRunCDCDaily(thruLabel="Nov 03, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_211104.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-02-19 tot_deaths        0      246      246 2.00000000
## 2   2020-02-20 tot_deaths        0      246      246 2.00000000
## 3   2020-02-21 tot_deaths        0      246      246 2.00000000
## 4   2020-02-22 tot_deaths        0      246      246 2.00000000
## 5   2020-02-23 tot_deaths        0      246      246 2.00000000
## 6   2020-02-24 tot_deaths        0      246      246 2.00000000
## 7   2020-02-25 tot_deaths        0      246      246 2.00000000
## 8   2020-02-26 tot_deaths        0      246      246 2.00000000
## 9   2020-02-08 tot_deaths        0      245      245 2.00000000
## 10  2020-02-09 tot_deaths        0      245      245 2.00000000
## 11  2020-02-10 tot_deaths        0      245      245 2.00000000
## 12  2020-02-11 tot_deaths        0      245      245 2.00000000
## 13  2020-02-12 tot_deaths        0      245      245 2.00000000
## 14  2020-02-13 tot_deaths        0      245      245 2.00000000
## 15  2020-02-14 tot_deaths        0      245      245 2.00000000
## 16  2020-02-15 tot_deaths        0      245      245 2.00000000
## 17  2020-02-16 tot_deaths        0      245      245 2.00000000
## 18  2020-02-17 tot_deaths        0      245      245 2.00000000
## 19  2020-02-18 tot_deaths        0      245      245 2.00000000
## 20  2020-02-03 tot_deaths        0      244      244 2.00000000
## 21  2020-02-04 tot_deaths        0      244      244 2.00000000
## 22  2020-02-05 tot_deaths        0      244      244 2.00000000
## 23  2020-02-06 tot_deaths        0      244      244 2.00000000
## 24  2020-02-07 tot_deaths        0      244      244 2.00000000
## 25  2020-02-27 tot_deaths        1      247      246 1.98387097
## 26  2020-02-28 tot_deaths        1      247      246 1.98387097
## 27  2020-02-29 tot_deaths        2      248      246 1.96800000
## 28  2020-03-01 tot_deaths        2      248      246 1.96800000
## 29  2020-03-02 tot_deaths        8      254      246 1.87786260
## 30  2020-03-03 tot_deaths       11      257      246 1.83582090
## 31  2020-03-04 tot_deaths       13      259      246 1.80882353
## 32  2020-03-05 tot_deaths       16      262      246 1.76978417
## 33  2020-03-06 tot_deaths       19      266      247 1.73333333
## 34  2020-03-07 tot_deaths       24      271      247 1.67457627
## 35  2020-03-08 tot_deaths       28      276      248 1.63157895
## 36  2020-03-09 tot_deaths       32      280      248 1.58974359
## 37  2020-03-10 tot_deaths       39      286      247 1.52000000
## 38  2020-03-11 tot_deaths       51      300      249 1.41880342
## 39  2020-03-12 tot_deaths       58      307      249 1.36438356
## 40  2020-03-13 tot_deaths       69      318      249 1.28682171
## 41  2020-03-14 tot_deaths       82      332      250 1.20772947
## 42  2020-03-15 tot_deaths      102      352      250 1.10132159
## 43  2020-03-16 tot_deaths      123      373      250 1.00806452
## 44  2020-03-17 tot_deaths      152      405      253 0.90843806
## 45  2020-03-18 tot_deaths      221      476      255 0.73170732
## 46  2020-03-19 tot_deaths      287      541      254 0.61352657
## 47  2020-03-20 tot_deaths      392      643      251 0.48502415
## 48  2020-03-21 tot_deaths      506      758      252 0.39873418
## 49  2020-03-22 tot_deaths      637      893      256 0.33464052
## 50  2020-03-23 tot_deaths      806     1064      258 0.27593583
## 51  2020-03-24 tot_deaths     1026     1298      272 0.23407917
## 52  2020-03-25 tot_deaths     1332     1610      278 0.18898708
## 53  2020-03-26 tot_deaths     1682     1963      281 0.15418381
## 54  2020-03-27 tot_deaths     2178     2467      289 0.12443488
## 55  2020-03-28 tot_deaths     2729     3011      282 0.09825784
## 56  2020-03-30 tot_deaths     4074     4377      303 0.07170749
## 57  2020-03-31 tot_deaths     5071     5387      316 0.06043221
## 58  2020-04-01 tot_deaths     6202     6527      325 0.05106450
## 59  2020-02-09  tot_cases       26      579      553 1.82809917
## 60  2020-02-06  tot_cases       24      533      509 1.82764811
## 61  2020-02-05  tot_cases       24      531      507 1.82702703
## 62  2020-02-11  tot_cases       27      597      570 1.82692308
## 63  2020-02-04  tot_cases       24      526      502 1.82545455
## 64  2020-02-10  tot_cases       27      588      561 1.82439024
## 65  2020-02-03  tot_cases       24      519      495 1.82320442
## 66  2020-02-12  tot_cases       28      605      577 1.82306477
## 67  2020-02-07  tot_cases       25      538      513 1.82238011
## 68  2020-02-08  tot_cases       26      546      520 1.81818182
## 69  2020-02-13  tot_cases       30      611      581 1.81279251
## 70  2020-02-14  tot_cases       31      617      586 1.80864198
## 71  2020-02-16  tot_cases       33      635      602 1.80239521
## 72  2020-02-15  tot_cases       33      622      589 1.79847328
## 73  2020-02-17  tot_cases       39      653      614 1.77456647
## 74  2020-02-18  tot_cases       44      660      616 1.75000000
## 75  2020-02-19  tot_cases       47      677      630 1.74033149
## 76  2020-02-20  tot_cases       49      691      642 1.73513514
## 77  2020-02-21  tot_cases       56      708      652 1.70680628
## 78  2020-02-23  tot_cases       63      757      694 1.69268293
## 79  2020-02-22  tot_cases       62      734      672 1.68844221
## 80  2020-02-24  tot_cases       71      776      705 1.66469894
## 81  2020-02-25  tot_cases       76      800      724 1.65296804
## 82  2020-02-26  tot_cases       86      844      758 1.63010753
## 83  2020-02-27  tot_cases       97      879      782 1.60245902
## 84  2020-02-28  tot_cases      105      930      825 1.59420290
## 85  2020-02-29  tot_cases      117      966      849 1.56786704
## 86  2020-03-01  tot_cases      149     1052      903 1.50374688
## 87  2020-03-02  tot_cases      192     1130      938 1.41906203
## 88  2020-03-03  tot_cases      266     1301     1035 1.32099553
## 89  2020-03-04  tot_cases      343     1444     1101 1.23223279
## 90  2020-03-05  tot_cases      430     1609     1179 1.15644924
## 91  2020-03-06  tot_cases      562     1827     1265 1.05902051
## 92  2020-03-07  tot_cases      734     2089     1355 0.95997166
## 93  2020-03-08  tot_cases      959     2444     1485 0.87275933
## 94  2020-03-09  tot_cases     1411     3040     1629 0.73197034
## 95  2020-03-10  tot_cases     1931     3716     1785 0.63219409
## 96  2020-03-11  tot_cases     2477     4569     2092 0.59381209
## 97  2020-03-12  tot_cases     3289     5713     2424 0.53854699
## 98  2020-03-13  tot_cases     4284     7079     2795 0.49194755
## 99  2020-03-14  tot_cases     5675     8933     3258 0.44605696
## 100 2020-03-15  tot_cases     7959    11743     3784 0.38412344
## 101 2020-03-16  tot_cases    10452    14682     4230 0.33659585
## 102 2020-03-17  tot_cases    13979    18729     4750 0.29044882
## 103 2020-03-18  tot_cases    19249    24821     5572 0.25287043
## 104 2020-03-19  tot_cases    25808    32036     6228 0.21533781
## 105 2020-03-20  tot_cases    33664    40317     6653 0.17985699
## 106 2020-03-21  tot_cases    43174    50375     7201 0.15395141
## 107 2020-03-22  tot_cases    54116    62013     7897 0.13600393
## 108 2020-03-23  tot_cases    65096    73411     8315 0.12006613
## 109 2020-03-24  tot_cases    76834    85682     8848 0.10888774
## 110 2020-03-25  tot_cases    91262   100538     9276 0.09672576
## 111 2020-03-26  tot_cases   110290   119932     9642 0.08376263
## 112 2020-03-27  tot_cases   130734   140627     9893 0.07291394
## 113 2020-03-28  tot_cases   151440   161456    10016 0.06402127
## 114 2020-03-30  tot_cases   193754   204591    10837 0.05441012
## 115 2021-06-06 new_deaths      441      230      211 0.62891207
## 116 2021-08-11 new_deaths      579      992      413 0.52577976
## 117 2021-03-22 new_deaths      951      594      357 0.46213592
## 118 2021-02-25 new_deaths     2863     1834     1029 0.43815201
## 119 2021-06-12 new_deaths      197      298      101 0.40808081
## 120 2021-07-06 new_deaths      294      206       88 0.35200000
## 121 2021-10-03 new_deaths      940      687      253 0.31100184
## 122 2021-07-12 new_deaths      306      229       77 0.28785047
## 123 2021-05-28 new_deaths      687      524      163 0.26919901
## 124 2021-07-01 new_deaths      288      220       68 0.26771654
## 125 2021-09-27 new_deaths     1471     1127      344 0.26481909
## 126 2021-03-28 new_deaths      616      473      143 0.26262626
## 127 2021-01-04 new_deaths     2247     2914      667 0.25847704
## 128 2021-03-25 new_deaths      990      767      223 0.25384178
## 129 2021-03-10 new_deaths     1562     1218      344 0.24748201
## 130 2021-05-02 new_deaths      522      409      113 0.24274973
## 131 2020-09-30 new_deaths      678      537      141 0.23209877
## 132 2021-09-26 new_deaths     1026      817      209 0.22680412
## 133 2021-03-24 new_deaths     1076      858      218 0.22543950
## 134 2021-05-01 new_deaths      636      508      128 0.22377622
## 135 2021-06-24 new_deaths      321      257       64 0.22145329
## 136 2021-06-25 new_deaths      397      319       78 0.21787709
## 137 2021-06-26 new_deaths      238      192       46 0.21395349
## 138 2021-03-27 new_deaths      836      676      160 0.21164021
## 139 2021-05-08 new_deaths      629      509      120 0.21089631
## 140 2021-03-04 new_deaths     1523     1235      288 0.20884699
## 141 2021-04-10 new_deaths      763      619      144 0.20839363
## 142 2020-12-28 new_deaths     2354     2899      545 0.20750048
## 143 2021-03-07 new_deaths      918      748      170 0.20408163
## 144 2021-09-24 new_deaths     2362     1925      437 0.20387217
## 145 2020-08-17 new_deaths      681      834      153 0.20198020
## 146 2021-03-26 new_deaths     1032      845      187 0.19925413
## 147 2021-03-17 new_deaths     1023      838      185 0.19881784
## 148 2020-08-31 new_deaths      564      688      124 0.19808307
## 149 2020-12-26 new_deaths     1839     2238      399 0.19573216
## 150 2020-09-07 new_deaths      458      557       99 0.19507389
## 151 2021-07-08 new_deaths      242      200       42 0.19004525
## 152 2021-02-26 new_deaths     1837     1519      318 0.18951132
## 153 2020-08-24 new_deaths      645      779      134 0.18820225
## 154 2021-06-18 new_deaths      276      229       47 0.18613861
## 155 2020-03-30 new_deaths      654      785      131 0.18207088
## 156 2021-03-13 new_deaths      948      791      157 0.18056354
## 157 2021-06-27 new_deaths      176      147       29 0.17956656
## 158 2020-09-14 new_deaths      451      539       88 0.17777778
## 159 2021-10-04 new_deaths     1233     1032      201 0.17748344
## 160 2021-03-18 new_deaths      847      709      138 0.17737789
## 161 2021-01-03 new_deaths     2149     2559      410 0.17417162
## 162 2021-04-02 new_deaths      813      683      130 0.17379679
## 163 2020-03-29 new_deaths      691      581      110 0.17295597
## 164 2020-12-27 new_deaths     2022     2404      382 0.17261636
## 165 2021-06-05 new_deaths      380      320       60 0.17142857
## 166 2021-04-01 new_deaths      818      689      129 0.17120106
## 167 2021-08-02 new_deaths      666      561      105 0.17114914
## 168 2021-10-02 new_deaths     1183      997      186 0.17064220
## 169 2021-07-16 new_deaths      359      303       56 0.16918429
## 170 2021-03-11 new_deaths     1302     1101      201 0.16729089
## 171 2021-01-19 new_deaths     2575     3042      467 0.16628093
## 172 2021-03-12 new_deaths     1266     1072      194 0.16595381
## 173 2021-02-28 new_deaths     1071      908      163 0.16472966
## 174 2021-09-25 new_deaths     1316     1116      200 0.16447368
## 175 2021-09-22 new_deaths     2123     1802      321 0.16356688
## 176 2021-09-23 new_deaths     2035     1730      305 0.16201859
## 177 2020-07-05 new_deaths      486      571       85 0.16083254
## 178 2021-06-11 new_deaths      402      343       59 0.15838926
## 179 2021-04-04 new_deaths      539      461       78 0.15600000
## 180 2021-02-27 new_deaths     1539     1318      221 0.15470774
## 181 2021-04-08 new_deaths      838      718      120 0.15424165
## 182 2020-09-05 new_deaths      783      671      112 0.15405777
## 183 2021-04-09 new_deaths      822      705      117 0.15324165
## 184 2021-06-20 new_deaths      227      195       32 0.15165877
## 185 2020-08-30 new_deaths      742      638      104 0.15072464
## 186 2021-03-05 new_deaths     1910     1643      267 0.15029552
## 187 2021-09-19 new_deaths     1203     1036      167 0.14917374
## 188 2020-10-02 new_deaths      896      772      124 0.14868106
## 189 2021-07-09 new_deaths      314      271       43 0.14700855
## 190 2021-03-19 new_deaths     1187     1025      162 0.14647378
## 191 2021-04-03 new_deaths      758      655      103 0.14578910
## 192 2020-09-28 new_deaths      449      518       69 0.14270941
## 193 2021-09-21 new_deaths     2217     1930      287 0.13841331
## 194 2020-07-13 new_deaths      757      867      110 0.13546798
## 195 2020-12-29 new_deaths     3313     3792      479 0.13483462
## 196 2021-04-15 new_deaths      787      688       99 0.13423729
## 197 2021-06-04 new_deaths      597      522       75 0.13404826
## 198 2021-05-29 new_deaths      307      351       44 0.13373860
## 199 2021-01-18 new_deaths     2405     2748      343 0.13312633
## 200 2021-07-11 new_deaths      127      145       18 0.13235294
## 201 2020-12-21 new_deaths     2346     2676      330 0.13142174
## 202 2021-03-06 new_deaths     1229     1078      151 0.13090594
## 203 2021-01-25 new_deaths     2214     2524      310 0.13085690
## 204 2021-01-12 new_deaths     3604     4107      503 0.13046297
## 205 2021-04-11 new_deaths      489      430       59 0.12840044
## 206 2020-07-27 new_deaths      981     1114      133 0.12696897
## 207 2021-02-20 new_deaths     1855     1634      221 0.12668386
## 208 2021-03-03 new_deaths     1546     1362      184 0.12654746
## 209 2021-09-15 new_deaths     2264     1996      268 0.12582160
## 210 2021-04-22 new_deaths      773      682       91 0.12508591
## 211 2021-02-05 new_deaths     3245     2863      382 0.12508186
## 212 2021-07-18 new_deaths      150      170       20 0.12500000
## 213 2021-07-25 new_deaths      249      282       33 0.12429379
## 214 2021-03-31 new_deaths      958      846      112 0.12416851
## 215 2021-09-28 new_deaths     1986     1754      232 0.12406417
## 216 2020-07-20 new_deaths      910     1029      119 0.12274368
## 217 2021-02-16 new_deaths     1413     1595      182 0.12101064
## 218 2021-10-01 new_deaths     2130     1889      241 0.11993033
## 219 2021-02-14 new_deaths     1511     1341      170 0.11921459
## 220 2021-05-05 new_deaths      712      632       80 0.11904762
## 221 2020-08-04 new_deaths     1081     1217      136 0.11836379
## 222 2020-08-23 new_deaths      851      756       95 0.11823273
## 223 2020-12-22 new_deaths     2901     3264      363 0.11776156
## 224 2021-07-17 new_deaths      176      198       22 0.11764706
## 225 2021-04-30 new_deaths      787      701       86 0.11559140
## 226 2020-07-28 new_deaths     1198     1343      145 0.11412830
## 227 2020-06-28 new_deaths      430      482       52 0.11403509
## 228 2020-08-18 new_deaths      922     1033      111 0.11355499
## 229 2021-04-14 new_deaths      784      700       84 0.11320755
## 230 2021-09-17 new_deaths     2208     1973      235 0.11241330
## 231 2020-06-30 new_deaths      630      705       75 0.11235955
## 232 2021-07-05 new_deaths      126      141       15 0.11235955
## 233 2020-09-23 new_deaths      908      812       96 0.11162791
## 234 2020-07-21 new_deaths     1194     1335      141 0.11150652
## 235 2021-09-11 new_deaths     1655     1481      174 0.11096939
## 236 2021-07-03 new_deaths      145      162       17 0.11074919
## 237 2021-04-17 new_deaths      642      576       66 0.10837438
## 238 2021-09-16 new_deaths     2039     1832      207 0.10694911
## 239 2021-05-07 new_deaths      800      719       81 0.10664911
## 240 2020-06-22 new_deaths      524      583       59 0.10659440
## 241 2021-01-11 new_deaths     2727     3032      305 0.10592117
## 242 2021-04-18 new_deaths      517      465       52 0.10590631
## 243 2020-08-11 new_deaths     1109     1233      124 0.10589240
## 244 2021-04-29 new_deaths      756      680       76 0.10584958
## 245 2020-09-02 new_deaths      878      791       87 0.10425404
## 246 2021-01-05 new_deaths     3384     3755      371 0.10393613
## 247 2020-09-19 new_deaths      659      594       65 0.10375100
## 248 2021-07-24 new_deaths      275      305       30 0.10344828
## 249 2021-05-16 new_deaths      462      417       45 0.10238908
## 250 2020-05-13 new_deaths     1488     1648      160 0.10204082
## 251 2020-12-20 new_deaths     2164     2396      232 0.10175439
## 252 2020-07-14 new_deaths      925     1024       99 0.10159056
## 253 2020-05-14 new_deaths     1967     1779      188 0.10037373
## 254 2021-02-18 new_deaths     2208     1997      211 0.10035672
## 255 2021-02-19 new_deaths     2346     2124      222 0.09932886
## 256 2020-09-01 new_deaths      869      959       90 0.09846827
## 257 2021-02-06 new_deaths     2570     2330      240 0.09795918
## 258 2021-07-02 new_deaths      300      272       28 0.09790210
## 259 2021-02-21 new_deaths     1448     1313      135 0.09779066
## 260 2021-07-19 new_deaths      291      264       27 0.09729730
## 261 2021-04-07 new_deaths      809      734       75 0.09721322
## 262 2020-07-06 new_deaths      650      716       66 0.09663250
## 263 2021-09-18 new_deaths     1495     1358      137 0.09603926
## 264 2021-09-30 new_deaths     1893     1721      172 0.09518539
## 265 2020-12-14 new_deaths     2150     2364      214 0.09481613
## 266 2021-05-06 new_deaths      669      609       60 0.09389671
## 267 2021-08-30 new_deaths     1210     1329      119 0.09373769
## 268 2021-02-02 new_deaths     2494     2739      245 0.09363654
## 269 2020-10-22 new_deaths      942      858       84 0.09333333
## 270 2020-12-15 new_deaths     2734     3000      266 0.09277991
## 271 2020-06-15 new_deaths      548      601       53 0.09225413
## 272 2020-08-28 new_deaths     1046      954       92 0.09200000
## 273 2021-02-04 new_deaths     3027     2764      263 0.09083060
## 274 2021-06-14 new_deaths      202      221       19 0.08983452
## 275 2020-10-08 new_deaths      745      681       64 0.08976157
## 276 2021-09-05 new_deaths     1295     1184      111 0.08955224
## 277 2021-06-23 new_deaths      340      311       29 0.08909370
## 278 2021-02-24 new_deaths     1985     1816      169 0.08892397
## 279 2021-07-26 new_deaths      423      387       36 0.08888889
## 280 2020-09-21 new_deaths      602      657       55 0.08737093
## 281 2021-05-09 new_deaths      420      385       35 0.08695652
## 282 2021-06-19 new_deaths      228      209       19 0.08695652
## 283 2021-09-10 new_deaths     2274     2087      187 0.08576015
## 284 2020-12-24 new_deaths     2979     3243      264 0.08486017
## 285 2020-10-12 new_deaths      542      590       48 0.08480565
## 286 2021-01-26 new_deaths     3122     3398      276 0.08466258
## 287 2020-08-10 new_deaths      849      924       75 0.08460237
## 288 2020-09-03 new_deaths      954      877       77 0.08410705
## 289 2021-04-28 new_deaths      831      764       67 0.08401254
## 290 2021-02-12 new_deaths     2382     2192      190 0.08307827
## 291 2021-09-29 new_deaths     2201     2030      171 0.08083195
## 292 2020-09-04 new_deaths      915      844       71 0.08072769
## 293 2020-06-23 new_deaths      718      778       60 0.08021390
## 294 2020-08-03 new_deaths      942     1020       78 0.07951070
## 295 2021-04-23 new_deaths      852      787       65 0.07931666
## 296 2020-09-24 new_deaths      751      694       57 0.07889273
## 297 2020-07-04 new_deaths      529      572       43 0.07811081
## 298 2021-06-03 new_deaths      466      431       35 0.07803790
## 299 2021-01-30 new_deaths     2783     2574      209 0.07802875
## 300 2021-02-11 new_deaths     3085     2854      231 0.07779087
## 301 2020-08-25 new_deaths      903      976       73 0.07770090
## 302 2020-09-12 new_deaths      647      599       48 0.07704655
## 303 2021-08-15 new_deaths      724      782       58 0.07702523
## 304 2021-02-09 new_deaths     2323     2509      186 0.07698675
## 305 2021-01-28 new_deaths     3392     3141      251 0.07684066
## 306 2020-10-15 new_deaths      748      693       55 0.07633588
## 307 2020-09-16 new_deaths     1063      985       78 0.07617188
## 308 2020-05-25 new_deaths      698      753       55 0.07580979
## 309 2021-09-09 new_deaths     2169     2011      158 0.07559809
## 310 2020-06-16 new_deaths      663      715       52 0.07547170
## 311 2021-05-22 new_deaths      427      396       31 0.07533414
## 312 2020-10-18 new_deaths      768      713       55 0.07427414
## 313 2021-01-02 new_deaths     2457     2646      189 0.07407407
## 314 2020-09-22 new_deaths      663      714       51 0.07407407
## 315 2021-07-10 new_deaths      143      154       11 0.07407407
## 316 2021-08-23 new_deaths     1132     1219       87 0.07401106
## 317 2020-10-03 new_deaths      560      603       43 0.07394669
## 318 2020-10-06 new_deaths      640      689       49 0.07373965
## 319 2021-04-21 new_deaths      750      697       53 0.07325501
## 320 2020-11-30 new_deaths     1721     1851      130 0.07278835
## 321 2021-01-10 new_deaths     2614     2810      196 0.07227139
## 322 2020-12-07 new_deaths     2156     2317      161 0.07198748
## 323 2020-10-28 new_deaths     1083     1008       75 0.07173601
## 324 2021-02-10 new_deaths     2751     2561      190 0.07153614
## 325 2020-12-08 new_deaths     2564     2752      188 0.07072987
## 326 2021-07-23 new_deaths      416      388       28 0.06965174
## 327 2021-05-12 new_deaths      702      655       47 0.06927045
## 328 2021-05-31 new_deaths      252      270       18 0.06896552
## 329 2020-05-26 new_deaths      843      903       60 0.06872852
## 330 2021-05-21 new_deaths      634      592       42 0.06851550
## 331 2020-08-12 new_deaths     1344     1255       89 0.06848788
## 332 2021-05-23 new_deaths      288      269       19 0.06822262
## 333 2020-07-10 new_deaths      940      878       62 0.06820682
## 334 2020-11-29 new_deaths     1397     1495       98 0.06777317
## 335 2020-06-29 new_deaths      502      537       35 0.06737247
## 336 2020-10-01 new_deaths      754      705       49 0.06716929
## 337 2021-08-16 new_deaths      835      893       58 0.06712963
## 338 2020-07-09 new_deaths      944      883       61 0.06677614
## 339 2020-08-09 new_deaths      916      857       59 0.06655386
## 340 2021-07-31 new_deaths      395      422       27 0.06609547
## 341 2020-09-06 new_deaths      706      661       45 0.06583760
## 342 2020-08-22 new_deaths      959      898       61 0.06569736
## 343 2021-03-14 new_deaths      678      635       43 0.06549886
## 344 2020-09-13 new_deaths      761      713       48 0.06512890
## 345 2020-09-18 new_deaths      825      773       52 0.06508135
## 346 2020-10-11 new_deaths      603      565       38 0.06506849
## 347 2020-12-12 new_deaths     2413     2572      159 0.06379137
## 348 2020-07-30 new_deaths     1448     1359       89 0.06341290
## 349 2021-08-17 new_deaths     1169     1245       76 0.06296603
## 350 2021-02-13 new_deaths     1988     1867      121 0.06277562
## 351 2021-09-01 new_deaths     1989     1868      121 0.06274306
## 352 2020-11-01 new_deaths      748      703       45 0.06202619
## 353 2021-01-20 new_deaths     3789     4031      242 0.06189258
## 354 2020-03-24 new_deaths      220      234       14 0.06167401
## 355 2021-06-17 new_deaths      285      268       17 0.06148282
## 356 2020-10-13 new_deaths      697      741       44 0.06119611
## 357 2021-07-04 new_deaths      127      135        8 0.06106870
## 358 2021-08-09 new_deaths      747      793       46 0.05974026
## 359 2020-11-16 new_deaths     1138     1208       70 0.05967604
## 360 2020-12-23 new_deaths     3211     3406      195 0.05893910
## 361 2021-06-10 new_deaths      402      379       23 0.05889885
## 362 2021-05-26 new_deaths      527      497       30 0.05859375
## 363 2020-09-29 new_deaths      813      862       49 0.05850746
## 364 2020-05-18 new_deaths      982     1041       59 0.05832921
## 365 2021-02-01 new_deaths     2083     2208      125 0.05826148
## 366 2021-03-09 new_deaths     1004     1064       60 0.05802708
## 367 2021-05-19 new_deaths      604      570       34 0.05792164
## 368 2021-05-20 new_deaths      534      504       30 0.05780347
## 369 2021-03-01 new_deaths     1229     1160       69 0.05776476
## 370 2020-06-08 new_deaths      795      842       47 0.05742211
## 371 2021-02-23 new_deaths     1647     1744       97 0.05721026
## 372 2021-01-06 new_deaths     3893     4121      228 0.05690042
## 373 2020-10-23 new_deaths      942      890       52 0.05676856
## 374 2020-08-14 new_deaths     1070     1011       59 0.05670351
## 375 2021-03-20 new_deaths      690      730       40 0.05633803
## 376 2021-04-05 new_deaths      384      406       22 0.05569620
## 377 2020-06-25 new_deaths      711      673       38 0.05491329
## 378 2020-09-26 new_deaths      674      638       36 0.05487805
## 379 2021-01-27 new_deaths     3655     3460      195 0.05481377
## 380 2021-04-25 new_deaths      450      426       24 0.05479452
## 381 2020-10-26 new_deaths      729      770       41 0.05470314
## 382 2021-07-15 new_deaths      321      304       17 0.05440000
## 383 2020-09-17 new_deaths      737      698       39 0.05435540
## 384 2020-11-03 new_deaths     1074     1134       60 0.05434783
## 385 2021-06-28 new_deaths      197      208       11 0.05432099
## 386 2021-04-06 new_deaths      686      724       38 0.05390071
## 387 2020-06-19 new_deaths      732      694       38 0.05329593
## 388 2021-08-10 new_deaths      943      993       50 0.05165289
## 389 2020-05-11 new_deaths     1096     1154       58 0.05155556
## 390 2021-08-24 new_deaths     1562     1644       82 0.05115409
## 391 2020-09-25 new_deaths      742      705       37 0.05114029
## 392 2021-04-16 new_deaths      803      763       40 0.05108557
## 393 2020-12-25 new_deaths     2367     2491      124 0.05104981
## 394 2021-05-14 new_deaths      684      650       34 0.05097451
## 395 2021-04-27 new_deaths      520      547       27 0.05060918
## 396 2020-11-02 new_deaths      813      855       42 0.05035971
## 397 2020-08-19 new_deaths     1248     1187       61 0.05010267
## 398 2020-02-09  new_cases        0       33       33 2.00000000
## 399 2020-02-16  new_cases        0       13       13 2.00000000
## 400 2020-02-11  new_cases        0        9        9 2.00000000
## 401 2020-02-04  new_cases        0        7        7 2.00000000
## 402 2020-02-23  new_cases        1       23       22 1.83333333
## 403 2020-02-10  new_cases        1        9        8 1.60000000
## 404 2020-02-08  new_cases        1        8        7 1.55555556
## 405 2020-02-12  new_cases        1        8        7 1.55555556
## 406 2020-02-20  new_cases        2       14       12 1.50000000
## 407 2020-02-03  new_cases        4       26       22 1.46666667
## 408 2020-02-28  new_cases        8       51       43 1.45762712
## 409 2020-02-19  new_cases        3       17       14 1.40000000
## 410 2020-02-25  new_cases        5       24       19 1.31034483
## 411 2020-02-26  new_cases       10       44       34 1.25925926
## 412 2020-02-22  new_cases        6       26       20 1.25000000
## 413 2020-02-27  new_cases       11       35       24 1.04347826
## 414 2020-02-29  new_cases       12       36       24 1.00000000
## 415 2020-02-17  new_cases        6       18       12 1.00000000
## 416 2020-03-01  new_cases       32       86       54 0.91525424
## 417 2020-02-21  new_cases        7       17       10 0.83333333
## 418 2020-02-24  new_cases        8       19       11 0.81481481
## 419 2020-03-03  new_cases       74      171       97 0.79183673
## 420 2020-03-05  new_cases       87      165       78 0.61904762
## 421 2020-03-04  new_cases       77      143       66 0.60000000
## 422 2020-03-02  new_cases       43       78       35 0.57851240
## 423 2020-03-06  new_cases      132      218       86 0.49142857
## 424 2020-03-08  new_cases      225      355      130 0.44827586
## 425 2020-03-11  new_cases      546      853      307 0.43888492
## 426 2021-06-30  new_cases    11473    17894     6421 0.43729356
## 427 2020-03-07  new_cases      172      262       90 0.41474654
## 428 2020-03-12  new_cases      812     1144      332 0.33946830
## 429 2020-03-13  new_cases      995     1366      371 0.31427361
## 430 2020-03-30  new_cases    15993    21742     5749 0.30470386
## 431 2020-03-14  new_cases     1391     1854      463 0.28536210
## 432 2020-05-13  new_cases    17768    23600     5832 0.28195707
## 433 2020-03-09  new_cases      452      596      144 0.27480916
## 434 2020-12-27  new_cases   156008   119489    36519 0.26511359
## 435 2021-08-02  new_cases   106092    81546    24546 0.26163144
## 436 2020-03-10  new_cases      520      676      156 0.26086957
## 437 2021-10-04  new_cases    90021    71127    18894 0.23449252
## 438 2021-07-26  new_cases    72995    58108    14887 0.22710388
## 439 2021-09-27  new_cases   107376    86322    21054 0.21738996
## 440 2021-07-19  new_cases    46704    37654     9050 0.21456175
## 441 2021-07-06  new_cases    20945    16896     4049 0.21400069
## 442 2021-07-11  new_cases    16761    20648     3887 0.20781095
## 443 2020-03-29  new_cases    26321    21393     4928 0.20656411
## 444 2020-03-15  new_cases     2284     2810      526 0.20651747
## 445 2021-07-12  new_cases    30021    24442     5579 0.20487303
## 446 2021-07-18  new_cases    28571    34924     6353 0.20011024
## 447 2021-07-04  new_cases    10306    12495     2189 0.19200912
## 448 2020-12-31  new_cases   231161   278813    47652 0.18688012
## 449 2021-07-17  new_cases    31623    37862     6239 0.17957833
## 450 2021-07-25  new_cases    43489    51945     8456 0.17721148
## 451 2021-07-05  new_cases     9336    11149     1813 0.17700757
## 452 2021-05-28  new_cases    24154    20325     3829 0.17217114
## 453 2021-07-10  new_cases    20528    24383     3855 0.17167286
## 454 2021-08-01  new_cases    63068    74674    11606 0.16851795
## 455 2020-03-16  new_cases     2493     2939      446 0.16421208
## 456 2021-07-03  new_cases    12986    15304     2318 0.16387416
## 457 2020-08-11  new_cases    61541    52255     9286 0.16320433
## 458 2020-08-15  new_cases    51474    44116     7358 0.15394916
## 459 2021-07-24  new_cases    52916    61584     8668 0.15140611
## 460 2020-05-14  new_cases    34697    29965     4732 0.14636108
## 461 2020-03-18  new_cases     5270     6092      822 0.14469284
## 462 2021-07-31  new_cases    80911    93240    12329 0.14158977
## 463 2020-03-17  new_cases     3527     4047      520 0.13731186
## 464 2021-01-03  new_cases   204160   179121    25039 0.13065610
## 465 2020-06-28  new_cases    37209    42343     5134 0.12907281
## 466 2020-07-06  new_cases    52042    45921     6121 0.12496555
## 467 2021-01-06  new_cases   262230   295251    33021 0.11846502
## 468 2020-12-30  new_cases   246663   276152    29489 0.11280855
## 469 2021-01-04  new_cases   176947   197846    20899 0.11152289
## 470 2020-06-17  new_cases    26594    29563     2969 0.10573927
## 471 2021-01-25  new_cases   134678   121822    12856 0.10024172
## 472 2020-06-26  new_cases    47543    52516     4973 0.09940135
## 473 2020-03-19  new_cases     6559     7215      656 0.09525192
## 474 2021-07-08  new_cases    28170    30696     2526 0.08582204
## 475 2020-06-25  new_cases    48479    52825     4346 0.08580115
## 476 2020-06-21  new_cases    27068    29469     2401 0.08493553
## 477 2021-06-27  new_cases    10461     9619      842 0.08386454
## 478 2020-08-12  new_cases    56265    51773     4492 0.08315593
## 479 2020-12-24  new_cases   201020   218257    17237 0.08222249
## 480 2020-07-09  new_cases    65119    70660     5541 0.08161792
## 481 2020-07-04  new_cases    49004    53159     4155 0.08134060
## 482 2020-06-20  new_cases    33948    36812     2864 0.08094969
## 483 2020-08-10  new_cases    44083    40663     3420 0.08071177
## 484 2021-09-26  new_cases    76428    82807     6379 0.08012058
## 485 2020-06-04  new_cases    21524    23309     1785 0.07962884
## 486 2020-06-18  new_cases    29829    32210     2381 0.07675817
## 487 2021-01-12  new_cases   226568   210291    16277 0.07451832
## 488 2020-06-27  new_cases    44751    48211     3460 0.07443902
## 489 2020-12-03  new_cases   224021   241314    17293 0.07432495
## 490 2021-01-02  new_cases   218437   202798    15639 0.07425309
## 491 2021-01-07  new_cases   267976   288619    20643 0.07417602
## 492 2021-01-17  new_cases   175155   163046    12109 0.07160830
## 493 2020-08-17  new_cases    40739    37962     2777 0.07057089
## 494 2021-07-07  new_cases    23008    24667     1659 0.06959622
## 495 2020-06-19  new_cases    33683    36109     2426 0.06952086
## 496 2020-08-23  new_cases    34825    32526     2299 0.06826922
## 497 2021-09-25  new_cases    91924    98375     6451 0.06779857
## 498 2021-01-18  new_cases   150824   140938     9886 0.06776756
## 499 2020-08-16  new_cases    39738    37134     2604 0.06774899
## 500 2021-07-14  new_cases    38514    41202     2688 0.06743941
## 501 2020-12-13  new_cases   173327   185082    11755 0.06559545
## 502 2020-07-05  new_cases    38831    41444     2613 0.06510121
## 503 2020-06-14  new_cases    19510    20783     1273 0.06318715
## 504 2020-06-10  new_cases    23111    24611     1500 0.06286409
## 505 2020-03-22  new_cases    10942    11638      696 0.06164748
## 506 2021-01-19  new_cases   156712   147342     9370 0.06163379
## 507 2020-12-10  new_cases   211460   224821    13361 0.06124952
## 508 2020-08-30  new_cases    34704    32645     2059 0.06114419
## 509 2020-07-10  new_cases    70260    74675     4415 0.06092386
## 510 2021-02-07  new_cases    87022    81908     5114 0.06054579
## 511 2020-12-02  new_cases   215178   228315    13137 0.05924333
## 512 2021-07-09  new_cases    27667    29325     1658 0.05818360
## 513 2021-07-28  new_cases    90794    96177     5383 0.05758112
## 514 2020-06-03  new_cases    21740    23026     1286 0.05745432
## 515 2020-07-21  new_cases    66698    62999     3699 0.05704064
## 516 2021-07-21  new_cases    62022    65663     3641 0.05703097
## 517 2020-06-24  new_cases    38812    41058     2246 0.05624139
## 518 2020-03-21  new_cases     9510    10058      548 0.05600981
## 519 2020-11-27  new_cases   158281   167382     9101 0.05589213
## 520 2020-05-29  new_cases    23478    24819     1341 0.05553140
## 521 2020-12-04  new_cases   228275   241170    12895 0.05493721
## 522 2021-08-30  new_cases   133221   126144     7077 0.05457174
## 523 2021-01-05  new_cases   261529   247769    13760 0.05403516
## 524 2020-06-12  new_cases    28247    29799     1552 0.05347483
## 525 2020-03-20  new_cases     7856     8281      425 0.05267398
## 526 2021-01-31  new_cases   107679   102181     5498 0.05239684
## 527 2020-12-09  new_cases   221701   233629    11928 0.05239277
## 528 2020-07-03  new_cases    60571    63799     3228 0.05190962
## 529 2020-07-02  new_cases    56724    59745     3021 0.05187646
## 530 2021-01-11  new_cases   201121   190955    10166 0.05185729
## 531 2020-06-07  new_cases    17171    18083      912 0.05173881
## 532 2020-07-12  new_cases    57261    60274     3013 0.05126983
## 533 2021-07-15  new_cases    40729    42871     2142 0.05124402
## 534 2020-06-15  new_cases    20387    21437     1050 0.05021041
## 535 2021-09-01  new_cases   201579   191720     9859 0.05013488

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name   newValue   refValue absDelta    pctDelta
## 1     CA tot_deaths   18843980   20243442  1399462 0.071606769
## 2     SC tot_deaths    3200530    3267283    66753 0.020641599
## 3     KY tot_deaths    2377709    2364995    12714 0.005361498
## 4     AL tot_deaths    3929590    3909338    20252 0.005167033
## 5     FL tot_deaths   13535198   13485213    49985 0.003699796
## 6     NM tot_deaths    1422780    1419795     2985 0.002100208
## 7     IN tot_deaths    4753969    4748538     5431 0.001143067
## 8     TN tot_deaths    3992595    3988072     4523 0.001133489
## 9     CA  tot_cases 1203611071 1258198901 54587830 0.044347720
## 10    KY  tot_cases  148749939  148486653   263286 0.001771558
## 11    KY new_deaths       9412       8906      506 0.055246206
## 12    FL new_deaths      58283      55622     2661 0.046723146
## 13    AL new_deaths      15216      14542      674 0.045298743
## 14    NM new_deaths       4938       4823      115 0.023563160
## 15    IN new_deaths      16059      15773      286 0.017969339
## 16    TN new_deaths      15592      15323      269 0.017402555
## 17    SC new_deaths      12711      12828      117 0.009162457
## 18    MS new_deaths       8856       8906       50 0.005629997
## 19    CA new_deaths      69039      68795      244 0.003540491
## 20    PR new_deaths       3181       3173        8 0.002518099
## 21    RI new_deaths       2846       2843        3 0.001054667
## 22    CA  new_cases    4569128    4724440   155312 0.033423546
## 23    KY  new_cases     708542     700393     8149 0.011567602
## 24    AL  new_cases     807657     802977     4680 0.005811376
## 25    TN  new_cases    1242274    1238023     4251 0.003427815
## 26    SC  new_cases     868898     866245     2653 0.003057961
## 27    PR  new_cases     181993     181797      196 0.001077545
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 39,060
## Columns: 15
## $ date           <date> 2021-09-01, 2020-07-14, 2021-02-02, 2021-09-19, 2020-0~
## $ state          <chr> "ND", "CA", "IL", "DE", "WI", "ND", "GU", "NC", "MI", "~
## $ tot_cases      <dbl> 118491, 336447, 1130917, 128253, 25480, 6602, 449, 8753~
## $ conf_cases     <dbl> 107475, 336447, 1130917, 117969, 22932, 6602, NA, 76009~
## $ prob_cases     <dbl> 11016, 0, 0, 10284, 2548, 0, NA, 115264, NA, 2026, NA, ~
## $ new_cases      <dbl> 536, 7285, 2304, 450, 185, 133, 15, 1614, 0, 621, 1379,~
## $ pnew_case      <dbl> 66, 0, 0, 36, 11, 0, 0, 450, NA, -11, NA, 0, 0, NA, -30~
## $ tot_deaths     <dbl> 1562, 7039, 21336, 1920, 700, 103, 5, 12363, 0, 3285, 4~
## $ conf_death     <dbl> NA, 7039, 19306, 1756, 694, NA, NA, 10933, NA, 2524, NA~
## $ prob_death     <dbl> NA, 0, 2030, 164, 6, NA, NA, 1430, NA, 761, NA, 0, NA, ~
## $ new_deaths     <dbl> 1, 25, 63, 0, 2, 0, 0, 16, 0, 66, 50, 165, 33, 0, 41, 1~
## $ pnew_death     <dbl> 0, 0, 16, 0, 0, 0, 0, 2, NA, 8, NA, 0, 0, NA, -10, 0, 0~
## $ created_at     <chr> "09/02/2021 01:49:05 PM", "07/16/2020 12:00:00 AM", "02~
## $ consent_cases  <chr> "Agree", "Agree", "Agree", "Agree", "Agree", "Agree", "~
## $ consent_deaths <chr> "Not agree", "Agree", "Agree", "Agree", "Agree", "Not a~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_211104.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     UT        inp   168021   167794      227 0.001351935
## 2     ME   hosp_ped      672      722       50 0.071736011
## 3     SC   hosp_ped     4707     4918      211 0.043844156
## 4     VT   hosp_ped      113      109        4 0.036036036
## 5     AR   hosp_ped     7953     7774      179 0.022763401
## 6     WV   hosp_ped     3008     3069       61 0.020075695
## 7     NM   hosp_ped     3979     3906       73 0.018516170
## 8     NJ   hosp_ped    10532    10704      172 0.016198908
## 9     DE   hosp_ped     2403     2436       33 0.013639182
## 10    AZ   hosp_ped    14960    15159      199 0.013214250
## 11    MA   hosp_ped     5669     5731       62 0.010877193
## 12    AL   hosp_ped    12322    12189      133 0.010852270
## 13    MS   hosp_ped     6395     6333       62 0.009742300
## 14    UT   hosp_ped     3909     3876       33 0.008477842
## 15    IN   hosp_ped     9883     9966       83 0.008363142
## 16    MO   hosp_ped    21187    21343      156 0.007335998
## 17    NC   hosp_ped    14766    14672       94 0.006386303
## 18    AK   hosp_ped     1059     1064        5 0.004710316
## 19    KY   hosp_ped     9043     9085       42 0.004633716
## 20    RI   hosp_ped     1705     1699        6 0.003525264
## 21    VA   hosp_ped     9082     9114       32 0.003517257
## 22    IA   hosp_ped     3553     3541       12 0.003383141
## 23    PA   hosp_ped    25525    25444       81 0.003178403
## 24    WA   hosp_ped     6319     6300       19 0.003011332
## 25    TN   hosp_ped    11881    11849       32 0.002697008
## 26    NH   hosp_ped      381      380        1 0.002628121
## 27    OH   hosp_ped    40021    39919      102 0.002551914
## 28    CA   hosp_ped    40162    40063       99 0.002468059
## 29    ND   hosp_ped     1779     1783        4 0.002245929
## 30    WY   hosp_ped      467      468        1 0.002139037
## 31    NV   hosp_ped     2739     2744        5 0.001823819
## 32    NE   hosp_ped     4153     4146        7 0.001686950
## 33    GA   hosp_ped    30374    30330       44 0.001449657
## 34    MN   hosp_ped     7296     7305        9 0.001232792
## 35    SD   hosp_ped     2714     2711        3 0.001105991
## 36    ME hosp_adult    48896    48821       75 0.001535045
## 37    NV hosp_adult   418591   418168      423 0.001011044
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 32,789
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_211104.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: Administered_Fed_LTC Administered_Fed_LTC_Residents Administered_Fed_LTC_Staff Administered_Fed_LTC_Unk Administered_Fed_LTC_Dose1 Administered_Fed_LTC_Dose1_Residents Administered_Fed_LTC_Dose1_Staff Administered_Fed_LTC_Dose1_Unk Series_Complete_FedLTC Series_Complete_FedLTC_Residents Series_Complete_FedLTC_Staff Series_Complete_FedLTC_Unknown
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 21,080
## Columns: 69
## $ date                                   <date> 2021-11-03, 2021-11-03, 2021-1~
## $ MMWR_week                              <dbl> 44, 44, 44, 44, 44, 44, 44, 44,~
## $ state                                  <chr> "DE", "NE", "VA", "NV", "MH", "~
## $ Distributed                            <dbl> 1740405, 2855740, 14218415, 440~
## $ Distributed_Janssen                    <dbl> 78800, 130700, 652600, 220200, ~
## $ Distributed_Moderna                    <dbl> 688300, 1073900, 5282260, 15782~
## $ Distributed_Pfizer                     <dbl> 962205, 1649940, 8196255, 26021~
## $ Distributed_Unk_Manuf                  <dbl> 11100, 1200, 87300, 6900, 0, 69~
## $ Dist_Per_100K                          <dbl> 178730, 147629, 166579, 143095,~
## $ Distributed_Per_100k_12Plus            <dbl> 207239, 176563, 194587, 168111,~
## $ Distributed_Per_100k_18Plus            <dbl> 225970, 195822, 213020, 184608,~
## $ Distributed_Per_100k_65Plus            <dbl> 921307, 913960, 1046310, 888669~
## $ vxa                                    <dbl> 1323750, 2363841, 11897204, 367~
## $ Administered_12Plus                    <dbl> 1323514, 2363455, 11865686, 367~
## $ Administered_18Plus                    <dbl> 1240381, 2204590, 11017333, 344~
## $ Administered_65Plus                    <dbl> 417001, 672166, 2858340, 938683~
## $ Administered_Janssen                   <dbl> 52330, 81726, 419235, 159195, 2~
## $ Administered_Moderna                   <dbl> 503446, 858215, 4230753, 127892~
## $ Administered_Pfizer                    <dbl> 766399, 1418876, 7240126, 22366~
## $ Administered_Unk_Manuf                 <dbl> 1575, 5024, 7090, 444, 2, 1659,~
## $ Admin_Per_100k                         <dbl> 135942, 122200, 139385, 119319,~
## $ Admin_Per_100k_12Plus                  <dbl> 157597, 146126, 162389, 140177,~
## $ Admin_Per_100k_18Plus                  <dbl> 161048, 151172, 165062, 144348,~
## $ Admin_Per_100k_65Plus                  <dbl> 220745, 215122, 210341, 189261,~
## $ Recip_Administered                     <dbl> 1297136, 2371830, 11887736, 364~
## $ Administered_Dose1_Recip               <dbl> 676471, 1183497, 6092097, 19595~
## $ Administered_Dose1_Pop_Pct             <dbl> 69.5, 61.2, 71.4, 63.6, 41.3, 7~
## $ Administered_Dose1_Recip_12Plus        <dbl> 676280, 1183205, 6073694, 19594~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 80.5, 73.2, 83.1, 74.7, 48.3, 8~
## $ Administered_Dose1_Recip_18Plus        <dbl> 634229, 1099541, 5631043, 18314~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 82.3, 75.4, 84.4, 76.7, 50.9, 8~
## $ Administered_Dose1_Recip_65Plus        <dbl> 193322, 293535, 1333722, 454040~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 99.9, 93.9, 98.1, 91.5, 13.4, 9~
## $ vxc                                    <dbl> 585496, 1090517, 5400472, 16368~
## $ vxcpoppct                              <dbl> 60.1, 56.4, 63.3, 53.1, 34.7, 7~
## $ Series_Complete_12Plus                 <dbl> 585442, 1090423, 5388380, 16368~
## $ Series_Complete_12PlusPop_Pct          <dbl> 69.7, 67.4, 73.7, 62.4, 40.7, 8~
## $ vxcgte18                               <dbl> 549593, 1015791, 4995190, 15392~
## $ vxcgte18pct                            <dbl> 71.4, 69.7, 74.8, 64.5, 44.5, 8~
## $ vxcgte65                               <dbl> 169840, 278310, 1191309, 392777~
## $ vxcgte65pct                            <dbl> 89.9, 89.1, 87.7, 79.2, 11.7, 9~
## $ Series_Complete_Janssen                <dbl> 51594, 80934, 404962, 156119, 2~
## $ Series_Complete_Moderna                <dbl> 212978, 391688, 1869775, 564207~
## $ Series_Complete_Pfizer                 <dbl> 320411, 616557, 3123032, 916524~
## $ Series_Complete_Unk_Manuf              <dbl> 513, 1338, 2703, 40, 1, 372, 14~
## $ Series_Complete_Janssen_12Plus         <dbl> 51585, 80916, 404867, 156115, 2~
## $ Series_Complete_Moderna_12Plus         <dbl> 212967, 391664, 1869605, 564203~
## $ Series_Complete_Pfizer_12Plus          <dbl> 320377, 616507, 3111213, 916492~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 513, 1336, 2695, 40, 1, 372, 14~
## $ Series_Complete_Janssen_18Plus         <dbl> 51538, 80860, 403425, 156075, 2~
## $ Series_Complete_Moderna_18Plus         <dbl> 212855, 391531, 1864225, 564107~
## $ Series_Complete_Pfizer_18Plus          <dbl> 284695, 542118, 2725010, 819040~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 505, 1282, 2530, 38, 1, 336, 13~
## $ Series_Complete_Janssen_65Plus         <dbl> 9370, 6570, 68922, 24477, 100, ~
## $ Series_Complete_Moderna_65Plus         <dbl> 69591, 135209, 557491, 182550, ~
## $ Series_Complete_Pfizer_65Plus          <dbl> 90603, 135700, 564052, 185728, ~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 276, 831, 844, 22, 0, 164, 37, ~
## $ Additional_Doses                       <dbl> 72183, 144543, 637226, 153957, ~
## $ Additional_Doses_Vax_Pct               <dbl> 12.3, 13.3, 11.8, 9.4, 0.5, 12.~
## $ Additional_Doses_18Plus                <dbl> 72119, 144363, 636427, 153845, ~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 13.1, 14.2, 12.7, 10.0, 0.5, 13~
## $ Additional_Doses_50Plus                <dbl> 63811, 116371, 514120, 129623, ~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 19.7, 21.6, 20.3, 16.3, 0.9, 20~
## $ Additional_Doses_65Plus                <dbl> 50550, 89179, 369537, 98301, 10~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 29.8, 32.0, 31.0, 25.0, 0.9, 31~
## $ Additional_Doses_Moderna               <dbl> 22244, 32403, 200336, 42487, 10~
## $ Additional_Doses_Pfizer                <dbl> 49616, 111328, 431133, 110631, ~
## $ Additional_Doses_Janssen               <dbl> 316, 736, 5457, 839, 0, 887, 11~
## $ Additional_Doses_Unk_Manuf             <dbl> 7, 76, 300, 0, 0, 135, 11, 61, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.21e+10    2.28e+8   4.58e+7 736156       38409    
## 2 after   1.20e+10    2.27e+8   4.56e+7 732594       33201    
## 3 pctchg  4.37e- 3    4.29e-3   4.61e-3      0.00484     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 33,201
## Columns: 6
## $ date       <date> 2021-09-01, 2020-07-14, 2021-02-02, 2021-09-19, 2020-06-15~
## $ state      <chr> "ND", "CA", "IL", "DE", "WI", "ND", "NC", "MI", "CT", "CT",~
## $ tot_cases  <dbl> 118491, 336447, 1130917, 128253, 25480, 6602, 875359, 0, 36~
## $ tot_deaths <dbl> 1562, 7039, 21336, 1920, 700, 103, 12363, 0, 3285, 494, 108~
## $ new_cases  <dbl> 536, 7285, 2304, 450, 185, 133, 1614, 0, 621, 1379, 7934, 1~
## $ new_deaths <dbl> 1, 25, 63, 0, 2, 0, 16, 0, 66, 50, 165, 33, 0, 41, 19, 15, ~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.53e+7    2.92e+7 648421      32789     
## 2 after  3.51e+7    2.90e+7 634350      31524     
## 3 pctchg 5.19e-3    5.06e-3      0.0217     0.0386
## 
## 
## Processed for cdcHosp:
## Rows: 31,524
## Columns: 5
## $ date       <date> 2020-10-14, 2020-10-14, 2020-10-11, 2020-10-10, 2020-10-09~
## $ state      <chr> "ID", "MN", "HI", "NH", "HI", "KS", "KS", "NH", "ME", "NJ",~
## $ inp        <dbl> 221, 625, 99, 45, 110, 476, 474, 52, 23, 579, 836, 156, 47,~
## $ hosp_adult <dbl> 219, 609, 99, 44, 108, 472, 454, 52, 23, 563, 423, 143, 47,~
## $ hosp_ped   <dbl> 2, 16, 0, 1, 2, 4, 5, 0, 0, 16, 1, 13, 0, 3, 1, 0, 3, 8, 29~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65  vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>        <dbl>    <dbl>       <dbl>
## 1 before 1.56e+11 6.82e+10 608084.    1.98e+10 1002949.     6.53e+10  737691.   
## 2 after  7.47e+10 3.30e+10 511921.    9.56e+ 9  914256.     3.16e+10  629721.   
## 3 pctchg 5.22e- 1 5.16e- 1      0.158 5.16e- 1       0.0884 5.17e- 1       0.146
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 16,575
## Columns: 9
## $ date        <date> 2021-11-03, 2021-11-03, 2021-11-03, 2021-11-03, 2021-11-0~
## $ state       <chr> "DE", "NE", "VA", "NV", "ME", "OK", "KY", "IL", "WV", "NM"~
## $ vxa         <dbl> 1323750, 2363841, 11897204, 3675224, 1998675, 4529434, 495~
## $ vxc         <dbl> 585496, 1090517, 5400472, 1636890, 951425, 1987280, 227231~
## $ vxcpoppct   <dbl> 60.1, 56.4, 63.3, 53.1, 70.8, 50.2, 50.9, 60.6, 41.1, 62.3~
## $ vxcgte65    <dbl> 169840, 278310, 1191309, 392777, 271435, 523238, 618148, 1~
## $ vxcgte65pct <dbl> 89.9, 89.1, 87.7, 79.2, 95.2, 82.4, 82.4, 86.0, 71.8, 88.5~
## $ vxcgte18    <dbl> 549593, 1015791, 4995190, 1539260, 896801, 1863794, 214494~
## $ vxcgte18pct <dbl> 71.4, 69.7, 74.8, 64.5, 81.9, 62.0, 61.9, 72.2, 49.1, 74.5~
## 
## Integrated per capita data file:
## Rows: 33,414
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_211104, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_211104.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The latest data are downloaded and processed:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_211202.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_211202.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_211202.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_211104")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_211104")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_211104")$dfRaw$vax
                    )

cdc_daily_211202 <- readRunCDCDaily(thruLabel="Dec 01, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_211202.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##           date       name newValue refValue absDelta   pctDelta
## 1   2020-01-22  tot_cases        0        7        7 2.00000000
## 2   2020-01-23  tot_cases        1        8        7 1.55555556
## 3   2020-01-24  tot_cases        2        9        7 1.27272727
## 4   2020-01-25  tot_cases        2        9        7 1.27272727
## 5   2020-01-28  tot_cases        3       11        8 1.14285714
## 6   2020-01-29  tot_cases        3       11        8 1.14285714
## 7   2020-01-30  tot_cases        3       11        8 1.14285714
## 8   2020-02-01  tot_cases        5       17       12 1.09090909
## 9   2020-01-26  tot_cases        3       10        7 1.07692308
## 10  2020-01-27  tot_cases        3       10        7 1.07692308
## 11  2020-01-31  tot_cases        4       13        9 1.05882353
## 12  2020-02-02  tot_cases        8       20       12 0.85714286
## 13  2020-02-17  tot_cases       16       39       23 0.83636364
## 14  2020-02-15  tot_cases       14       33       19 0.80851064
## 15  2020-02-16  tot_cases       14       33       19 0.80851064
## 16  2020-02-10  tot_cases       12       27       15 0.76923077
## 17  2020-02-11  tot_cases       12       27       15 0.76923077
## 18  2020-02-14  tot_cases       14       31       17 0.75555556
## 19  2020-02-03  tot_cases       11       24       13 0.74285714
## 20  2020-02-04  tot_cases       11       24       13 0.74285714
## 21  2020-02-05  tot_cases       11       24       13 0.74285714
## 22  2020-02-06  tot_cases       11       24       13 0.74285714
## 23  2020-02-08  tot_cases       12       26       14 0.73684211
## 24  2020-02-09  tot_cases       12       26       14 0.73684211
## 25  2020-02-12  tot_cases       13       28       15 0.73170732
## 26  2020-02-13  tot_cases       14       30       16 0.72727273
## 27  2020-02-18  tot_cases       21       44       23 0.70769231
## 28  2020-02-07  tot_cases       12       25       13 0.70270270
## 29  2020-02-20  tot_cases       25       49       24 0.64864865
## 30  2020-02-19  tot_cases       24       47       23 0.64788732
## 31  2020-02-21  tot_cases       30       56       26 0.60465116
## 32  2020-02-24  tot_cases       40       71       31 0.55855856
## 33  2020-02-23  tot_cases       36       63       27 0.54545455
## 34  2020-02-25  tot_cases       44       76       32 0.53333333
## 35  2020-02-22  tot_cases       36       62       26 0.53061224
## 36  2020-02-28  tot_cases       61      105       44 0.53012048
## 37  2020-02-27  tot_cases       57       97       40 0.51948052
## 38  2020-03-01  tot_cases       88      149       61 0.51476793
## 39  2020-02-29  tot_cases       70      117       47 0.50267380
## 40  2020-02-26  tot_cases       52       86       34 0.49275362
## 41  2020-03-02  tot_cases      124      192       68 0.43037975
## 42  2020-03-03  tot_cases      188      266       78 0.34361233
## 43  2020-03-04  tot_cases      255      343       88 0.29431438
## 44  2020-03-05  tot_cases      333      430       97 0.25425950
## 45  2020-03-06  tot_cases      454      562      108 0.21259843
## 46  2020-03-07  tot_cases      614      734      120 0.17804154
## 47  2020-03-08  tot_cases      823      959      136 0.15263749
## 48  2020-03-09  tot_cases     1243     1411      168 0.12660136
## 49  2020-03-10  tot_cases     1736     1931      195 0.10635397
## 50  2020-03-14  tot_cases     5140     5675      535 0.09893666
## 51  2020-03-11  tot_cases     2250     2477      227 0.09604400
## 52  2020-03-12  tot_cases     2998     3289      291 0.09257197
## 53  2020-03-13  tot_cases     3909     4284      375 0.09154156
## 54  2020-03-15  tot_cases     7342     7959      617 0.08064832
## 55  2020-03-17  tot_cases    12913    13979     1066 0.07928008
## 56  2020-03-18  tot_cases    17816    19249     1433 0.07732362
## 57  2020-03-16  tot_cases     9691    10452      761 0.07555975
## 58  2020-03-19  tot_cases    23990    25808     1818 0.07301498
## 59  2020-03-20  tot_cases    31427    33664     2237 0.06873454
## 60  2020-03-21  tot_cases    40645    43174     2529 0.06034431
## 61  2021-10-30 new_deaths      414      254      160 0.47904192
## 62  2021-10-31 new_deaths      287      185      102 0.43220339
## 63  2021-10-23 new_deaths      648      465      183 0.32884097
## 64  2021-10-24 new_deaths      329      238       91 0.32098765
## 65  2021-10-16 new_deaths      904      760      144 0.17307692
## 66  2021-02-02 new_deaths     2954     2494      460 0.16886931
## 67  2021-01-28 new_deaths     3855     3392      463 0.12777701
## 68  2021-05-31 new_deaths      222      252       30 0.12658228
## 69  2021-07-05 new_deaths      111      126       15 0.12658228
## 70  2021-01-26 new_deaths     3542     3122      420 0.12605042
## 71  2021-07-11 new_deaths      113      127       14 0.11666667
## 72  2020-11-15 new_deaths     1045     1172      127 0.11456924
## 73  2021-11-01 new_deaths     1139     1267      128 0.10640067
## 74  2021-10-09 new_deaths     1033      929      104 0.10601427
## 75  2021-07-24 new_deaths      248      275       27 0.10325048
## 76  2021-06-19 new_deaths      252      228       24 0.10000000
## 77  2020-03-20 new_deaths       95      105       10 0.10000000
## 78  2021-10-12 new_deaths     1931     1754      177 0.09606513
## 79  2021-10-02 new_deaths     1298     1183      115 0.09270455
## 80  2021-02-01 new_deaths     2283     2083      200 0.09161704
## 81  2020-12-26 new_deaths     1680     1839      159 0.09036658
## 82  2021-06-13 new_deaths      149      163       14 0.08974359
## 83  2020-12-06 new_deaths     1622     1771      149 0.08782788
## 84  2021-01-27 new_deaths     3989     3655      334 0.08738880
## 85  2021-07-08 new_deaths      264      242       22 0.08695652
## 86  2020-11-29 new_deaths     1281     1397      116 0.08663181
## 87  2021-10-17 new_deaths      676      621       55 0.08481110
## 88  2020-09-07 new_deaths      421      458       37 0.08418658
## 89  2021-08-15 new_deaths      667      724       57 0.08195543
## 90  2021-08-08 new_deaths      523      567       44 0.08073394
## 91  2021-09-25 new_deaths     1426     1316      110 0.08023341
## 92  2020-11-02 new_deaths      752      813       61 0.07795527
## 93  2020-11-28 new_deaths     1494     1614      120 0.07722008
## 94  2021-01-04 new_deaths     2086     2247      161 0.07431341
## 95  2021-06-12 new_deaths      212      197       15 0.07334963
## 96  2021-10-14 new_deaths     1539     1432      107 0.07202962
## 97  2020-10-12 new_deaths      505      542       37 0.07067813
## 98  2021-02-06 new_deaths     2756     2570      186 0.06984604
## 99  2020-10-25 new_deaths      614      658       44 0.06918239
## 100 2021-09-22 new_deaths     2274     2123      151 0.06868319
## 101 2021-09-08 new_deaths     2050     1916      134 0.06757438
## 102 2020-11-16 new_deaths     1064     1138       74 0.06721163
## 103 2020-12-27 new_deaths     1891     2022      131 0.06695630
## 104 2020-11-30 new_deaths     1610     1721      111 0.06664665
## 105 2021-09-20 new_deaths     1305     1221       84 0.06650831
## 106 2020-07-05 new_deaths      455      486       31 0.06588735
## 107 2021-10-20 new_deaths     1739     1629      110 0.06532067
## 108 2020-11-22 new_deaths     1307     1395       88 0.06513694
## 109 2020-12-25 new_deaths     2218     2367      149 0.06499455
## 110 2021-02-21 new_deaths     1545     1448       97 0.06481791
## 111 2021-01-19 new_deaths     2747     2575      172 0.06463735
## 112 2020-09-28 new_deaths      421      449       28 0.06436782
## 113 2021-09-28 new_deaths     2118     1986      132 0.06432749
## 114 2021-10-26 new_deaths     1995     1871      124 0.06414899
## 115 2020-12-07 new_deaths     2022     2156      134 0.06414552
## 116 2021-09-06 new_deaths     1063     1133       70 0.06375228
## 117 2021-09-12 new_deaths     1132     1206       74 0.06330197
## 118 2021-05-22 new_deaths      401      427       26 0.06280193
## 119 2020-12-21 new_deaths     2208     2346      138 0.06060606
## 120 2021-10-19 new_deaths     1834     1727      107 0.06009548
## 121 2020-08-24 new_deaths      608      645       37 0.05905826
## 122 2021-03-23 new_deaths      743      701       42 0.05817175
## 123 2021-08-31 new_deaths     1755     1656       99 0.05804749
## 124 2020-11-09 new_deaths      961     1018       57 0.05760485
## 125 2021-07-04 new_deaths      120      127        7 0.05668016
## 126 2021-06-29 new_deaths      278      263       15 0.05545287
## 127 2021-09-14 new_deaths     2403     2274      129 0.05516357
## 128 2021-02-12 new_deaths     2517     2382      135 0.05511329
## 129 2021-01-03 new_deaths     2034     2149      115 0.05498446
## 130 2020-03-22 new_deaths      124      131        7 0.05490196
## 131 2020-03-23 new_deaths      160      169        9 0.05471125
## 132 2020-10-09 new_deaths      792      750       42 0.05447471
## 133 2021-09-18 new_deaths     1578     1495       83 0.05401887
## 134 2021-02-05 new_deaths     3423     3245      178 0.05338932
## 135 2021-09-15 new_deaths     2388     2264      124 0.05331040
## 136 2020-12-14 new_deaths     2040     2150      110 0.05250597
## 137 2021-10-29 new_deaths     1726     1819       93 0.05246827
## 138 2021-10-15 new_deaths     1987     1887      100 0.05162623
## 139 2021-10-18 new_deaths     1262     1199       63 0.05119870
## 140 2020-08-03 new_deaths      895      942       47 0.05117039
## 141 2020-11-01 new_deaths      711      748       37 0.05071967
## 142 2021-05-27 new_deaths      548      521       27 0.05051450
## 143 2021-10-05 new_deaths     2037     1937      100 0.05032713
## 144 2020-01-22  new_cases        0        7        7 2.00000000
## 145 2020-02-27  new_cases        5       11        6 0.75000000
## 146 2020-03-01  new_cases       18       32       14 0.56000000
## 147 2020-03-02  new_cases       36       43        7 0.17721519
## 148 2021-10-30  new_cases    28712    24628     4084 0.15313086
## 149 2021-10-23  new_cases    29620    25597     4023 0.14571599
## 150 2021-05-13  new_cases    41011    35463     5548 0.14509506
## 151 2020-03-03  new_cases       64       74       10 0.14492754
## 152 2021-10-31  new_cases    20545    17870     2675 0.13926851
## 153 2020-03-04  new_cases       67       77       10 0.13888889
## 154 2021-10-24  new_cases    23600    20557     3043 0.13782639
## 155 2020-03-14  new_cases     1231     1391      160 0.12204424
## 156 2021-03-14  new_cases    47257    42079     5178 0.11592191
## 157 2021-09-12  new_cases   116283   104092    12191 0.11063868
## 158 2020-03-05  new_cases       78       87        9 0.10909091
## 159 2021-09-06  new_cases   110307   100261    10046 0.09541811
## 160 2020-03-17  new_cases     3222     3527      305 0.09038376
## 161 2020-03-13  new_cases      911      995       84 0.08814271
## 162 2020-03-06  new_cases      121      132       11 0.08695652
## 163 2020-09-06  new_cases    33988    31178     2810 0.08624129
## 164 2020-07-07  new_cases    56061    60897     4836 0.08269635
## 165 2020-10-13  new_cases    50814    55179     4365 0.08236393
## 166 2020-03-12  new_cases      748      812       64 0.08205128
## 167 2021-08-24  new_cases   163795   177621    13826 0.08099210
## 168 2020-07-26  new_cases    59006    54567     4439 0.07816999
## 169 2020-09-09  new_cases    35564    38421     2857 0.07723187
## 170 2021-09-11  new_cases   153160   141855    11305 0.07664017
## 171 2021-10-25  new_cases    94603   102106     7503 0.07628527
## 172 2020-12-29  new_cases   210249   226862    16613 0.07601273
## 173 2020-03-08  new_cases      209      225       16 0.07373272
## 174 2020-03-09  new_cases      420      452       32 0.07339450
## 175 2021-09-05  new_cases   124666   115881     8785 0.07304186
## 176 2020-03-07  new_cases      160      172       12 0.07228916
## 177 2020-03-18  new_cases     4903     5270      367 0.07215177
## 178 2020-08-09  new_cases    46359    43144     3215 0.07184117
## 179 2020-05-27  new_cases    20368    21843     1475 0.06988700
## 180 2021-09-08  new_cases   169999   181743    11744 0.06677622
## 181 2021-08-17  new_cases   150835   161030    10195 0.06538085
## 182 2021-01-05  new_cases   245060   261529    16469 0.06501918
## 183 2020-06-09  new_cases    18594    19823     1229 0.06398209
## 184 2021-09-07  new_cases   118424   111103     7321 0.06379206
## 185 2020-09-20  new_cases    34275    32172     2103 0.06329857
## 186 2020-06-02  new_cases    20731    22082     1351 0.06311167
## 187 2020-08-23  new_cases    37081    34825     2256 0.06274859
## 188 2021-09-19  new_cases    97060    91238     5822 0.06183815
## 189 2020-09-29  new_cases    38935    41374     2439 0.06074039
## 190 2020-03-19  new_cases     6174     6559      385 0.06047279
## 191 2021-08-22  new_cases   127065   119611     7454 0.06043555
## 192 2020-03-11  new_cases      514      546       32 0.06037736
## 193 2020-03-16  new_cases     2349     2493      144 0.05947955
## 194 2020-07-19  new_cases    59921    56578     3343 0.05739105
## 195 2020-09-27  new_cases    35369    33408     1961 0.05702488
## 196 2020-11-24  new_cases   175932   186115    10183 0.05625237
## 197 2021-09-22  new_cases   132374   125190     7184 0.05578419
## 198 2020-06-14  new_cases    20620    19510     1110 0.05532021
## 199 2020-10-18  new_cases    48992    46360     2632 0.05520597
## 200 2020-10-27  new_cases    75829    80102     4273 0.05480629
## 201 2020-03-20  new_cases     7437     7856      419 0.05479631
## 202 2020-08-30  new_cases    36631    34704     1927 0.05402678
## 203 2020-10-20  new_cases    58978    62239     3261 0.05380433
## 204 2020-12-01  new_cases   192552   203130    10578 0.05346718
## 205 2020-08-16  new_cases    41920    39738     2182 0.05344241
## 206 2020-03-10  new_cases      493      520       27 0.05330701
## 207 2020-07-21  new_cases    63329    66698     3369 0.05182001
## 208 2021-04-17  new_cases    78012    74105     3907 0.05136835
## 209 2020-06-16  new_cases    24926    26235     1309 0.05117179
## 210 2020-12-26  new_cases   149192   141757     7435 0.05110861
## 211 2021-08-10  new_cases   136592   143746     7154 0.05103839
## 212 2020-09-01  new_cases    38841    40860     2019 0.05066436
## 213 2021-02-07  new_cases    91485    87022     4463 0.05000364

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name  newValue  refValue absDelta    pctDelta
## 1     NM tot_deaths   1453354   1567848   114494 0.075793674
## 2     IN tot_deaths   5028752   5231738   202986 0.039566531
## 3     TN tot_deaths   4322924   4457205   134281 0.030587478
## 4     PR tot_deaths    879235    905115    25880 0.029007762
## 5     KY tot_deaths   2732412   2656872    75540 0.028033409
## 6     NC tot_deaths   4962428   4921441    40987 0.008293716
## 7     SC tot_deaths   3569982   3587043    17061 0.004767623
## 8     FL tot_deaths  15304365  15252950    51415 0.003365152
## 9     AL tot_deaths   4391384   4376851    14533 0.003314920
## 10    AL  tot_cases 209779785 216389881  6610096 0.031020960
## 11    TN  tot_cases 320105241 325227756  5122515 0.015875571
## 12    NC  tot_cases 361373848 364334848  2961000 0.008160299
## 13    PR  tot_cases  47364624  47669074   304450 0.006407201
## 14    KY  tot_cases 169191874 169942936   751062 0.004429283
## 15    KY new_deaths     10662      9834      828 0.080796253
## 16    NM new_deaths      4856      5073      217 0.043710343
## 17    FL new_deaths     61112     59499     1613 0.026747146
## 18    AL new_deaths     16002     15676      326 0.020582107
## 19    NC new_deaths     18393     18130      263 0.014401884
## 20    PR new_deaths      3227      3236        9 0.002785084
## 21    KY  new_cases    749093    746588     2505 0.003349645
## 22    AL  new_cases    831486    833493     2007 0.002410841
## 23    PR  new_cases    184589    185001      412 0.002229498
## 24    NC  new_cases   1485886   1483678     2208 0.001487087
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 40,800
## Columns: 15
## $ date           <date> 2021-04-01, 2021-05-31, 2020-06-13, 2021-02-02, 2021-0~
## $ state          <chr> "CA", "CA", "AL", "IL", "DE", "WI", "NC", "ND", "GU", "~
## $ tot_cases      <dbl> 3570660, 3685032, 25331, 1130917, 128253, 25480, 14513,~
## $ conf_cases     <dbl> 3570660, 3685032, 24985, 1130917, 117969, 22932, 14513,~
## $ prob_cases     <dbl> 0, 0, 346, 0, 10284, 2548, 0, 0, NA, 44, 194969, NA, NA~
## $ new_cases      <dbl> 2234, 644, 959, 2304, 450, 185, 467, 133, 15, 121, 1558~
## $ pnew_case      <dbl> 0, 0, 5, 0, 36, 11, 0, 0, 0, 4, 489, NA, 0, -11, 94, 0,~
## $ tot_deaths     <dbl> 58090, 62011, 1062, 21336, 1920, 700, 589, 103, 5, 41, ~
## $ conf_death     <dbl> 58090, 62011, 987, 19306, 1756, 694, 589, NA, NA, 38, 1~
## $ prob_death     <dbl> 0, 0, 75, 2030, 164, 6, 0, NA, NA, 3, 3354, NA, 416, 76~
## $ new_deaths     <dbl> 154, 5, 8, 63, 0, 2, 19, 0, 0, 9, 46, 0, 16, 66, 8, 165~
## $ pnew_death     <dbl> 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 13, NA, 0, 8, 0, 0, 0, N~
## $ created_at     <chr> "04/03/2021 12:00:00 AM", "06/02/2021 12:00:00 AM", "06~
## $ consent_cases  <chr> "Agree", "Agree", "Agree", "Agree", "Agree", "Agree", "~
## $ consent_deaths <chr> "Agree", "Agree", "Agree", "Agree", "Agree", "Agree", "~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_211202.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date     name newValue refValue absDelta   pctDelta
## 1 2020-08-02 hosp_ped     4362     4629      267 0.05939273
## 2 2020-07-25 hosp_ped     4553     4325      228 0.05136292

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     ME   hosp_ped      668      724       56 0.080459770
## 2     SC   hosp_ped     5227     5032      195 0.038015401
## 3     WV   hosp_ped     3334     3242       92 0.027980535
## 4     DE   hosp_ped     2662     2595       67 0.025489823
## 5     KY   hosp_ped    10521    10331      190 0.018223672
## 6     NV   hosp_ped     2939     2890       49 0.016812489
## 7     KS   hosp_ped     2663     2708       45 0.016756656
## 8     ID   hosp_ped     2178     2146       32 0.014801110
## 9     AR   hosp_ped     8128     8249      121 0.014776821
## 10    NM   hosp_ped     4152     4196       44 0.010541447
## 11    NJ   hosp_ped    10988    10880      108 0.009877446
## 12    NH   hosp_ped      426      430        4 0.009345794
## 13    AK   hosp_ped     1259     1249       10 0.007974482
## 14    MA   hosp_ped     5859     5904       45 0.007651109
## 15    UT   hosp_ped     4339     4306       33 0.007634471
## 16    AL   hosp_ped    12888    12986       98 0.007575172
## 17    VA   hosp_ped     9770     9709       61 0.006263155
## 18    MS   hosp_ped     6850     6891       41 0.005967542
## 19    MO   hosp_ped    22827    22713      114 0.005006588
## 20    TN   hosp_ped    12536    12590       54 0.004298336
## 21    WY   hosp_ped      497      495        2 0.004032258
## 22    NE   hosp_ped     4381     4395       14 0.003190520
## 23    IA   hosp_ped     4029     4041       12 0.002973978
## 24    AZ   hosp_ped    16178    16132       46 0.002847416
## 25    IL   hosp_ped    25073    25144       71 0.002827728
## 26    GA   hosp_ped    32017    32084       67 0.002090451
## 27    CO   hosp_ped    12851    12876       25 0.001943483
## 28    CA   hosp_ped    42407    42486       79 0.001861166
## 29    PA   hosp_ped    28019    28071       52 0.001854163
## 30    HI   hosp_ped     1390     1392        2 0.001437815
## 31    MI   hosp_ped    11782    11795       13 0.001102770
## 32    CT   hosp_ped     2916     2919        3 0.001028278
## 33    NC hosp_adult   819100   818128      972 0.001187373
## 34    NM hosp_adult   151665   151488      177 0.001167727
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 34,355
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_211202.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: Administered_Dose1_Recip_5Plus Administered_Dose1_Recip_5PlusPop_Pct Series_Complete_5Plus Series_Complete_5PlusPop_Pct Administered_5Plus Admin_Per_100k_5Plus Distributed_Per_100k_5Plus Series_Complete_Moderna_5Plus Series_Complete_Pfizer_5Plus Series_Complete_Janssen_5Plus Series_Complete_Unk_Manuf_5Plus
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 29
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 22,936
## Columns: 80
## $ date                                   <date> 2021-12-02, 2021-12-02, 2021-1~
## $ MMWR_week                              <dbl> 48, 48, 48, 48, 48, 48, 48, 48,~
## $ state                                  <chr> "CO", "KS", "MT", "FM", "TN", "~
## $ Distributed                            <dbl> 10264195, 4840995, 1662025, 104~
## $ Distributed_Janssen                    <dbl> 459500, 240600, 98800, 12200, 4~
## $ Distributed_Moderna                    <dbl> 3874940, 1914040, 689280, 80440~
## $ Distributed_Pfizer                     <dbl> 5929755, 2686355, 873945, 12180~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 178237, 166168, 155507, 102443,~
## $ Distributed_Per_100k_12Plus            <dbl> 207943, 197455, 181128, 132445,~
## $ Distributed_Per_100k_18Plus            <dbl> 228133, 218746, 197815, 157095,~
## $ Distributed_Per_100k_65Plus            <dbl> 1218430, 1018110, 805100, 21783~
## $ vxa                                    <dbl> 8678461, 3728475, 1333956, 8004~
## $ Administered_12Plus                    <dbl> 8542236, 3685928, 1321921, 8003~
## $ Administered_18Plus                    <dbl> 8001344, 3448406, 1254563, 7790~
## $ Administered_65Plus                    <dbl> 2014555, 1084652, 448504, 6161,~
## $ Administered_Janssen                   <dbl> 307987, 121410, 54642, 12315, 2~
## $ Administered_Moderna                   <dbl> 3411615, 1453194, 567864, 65527~
## $ Administered_Pfizer                    <dbl> 4952061, 2150807, 709888, 2205,~
## $ Administered_Unk_Manuf                 <dbl> 6798, 3064, 1562, 2, 40505, 134~
## $ Admin_Per_100k                         <dbl> 150701, 127981, 124811, 78234, ~
## $ Admin_Per_100k_12Plus                  <dbl> 173058, 150342, 144063, 101127,~
## $ Admin_Per_100k_18Plus                  <dbl> 177839, 155820, 149319, 116751,~
## $ Admin_Per_100k_65Plus                  <dbl> 239141, 228114, 217260, 128034,~
## $ Recip_Administered                     <dbl> 8651457, 3830030, 1332315, 8076~
## $ Administered_Dose1_Recip               <dbl> 4129805, 1936837, 641463, 47744~
## $ Administered_Dose1_Pop_Pct             <dbl> 71.7, 66.5, 60.0, 46.7, 57.0, 8~
## $ Administered_Dose1_Recip_12Plus        <dbl> 4016267, 1898566, 630102, 47729~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 81.4, 77.4, 68.7, 60.3, 65.9, 9~
## $ Administered_Dose1_Recip_18Plus        <dbl> 3731095, 1768923, 593977, 46547~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 82.9, 79.9, 70.7, 69.8, 68.4, 9~
## $ Administered_Dose1_Recip_65Plus        <dbl> 811378, 505368, 190045, 3636, 1~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 96.3, 99.9, 92.1, 75.6, 89.1, 9~
## $ vxc                                    <dbl> 3655321, 1598588, 555986, 42465~
## $ vxcpoppct                              <dbl> 63.5, 54.9, 52.0, 41.5, 49.7, 5~
## $ Series_Complete_12Plus                 <dbl> 3633081, 1593743, 555315, 42456~
## $ Series_Complete_12PlusPop_Pct          <dbl> 73.6, 65.0, 60.5, 53.6, 58.1, 6~
## $ vxcgte18                               <dbl> 3379360, 1485220, 524950, 41485~
## $ vxcgte18pct                            <dbl> 75.1, 67.1, 62.5, 62.2, 60.5, 6~
## $ vxcgte65                               <dbl> 742632, 415555, 172382, 3382, 9~
## $ vxcgte65pct                            <dbl> 88.2, 87.4, 83.5, 70.3, 81.7, 8~
## $ Series_Complete_Janssen                <dbl> 290214, 114775, 50802, 11767, 2~
## $ Series_Complete_Moderna                <dbl> 1362844, 597783, 225768, 29567,~
## $ Series_Complete_Pfizer                 <dbl> 2000377, 885480, 279046, 1129, ~
## $ Series_Complete_Unk_Manuf              <dbl> 1886, 550, 370, 2, 9615, 582, 7~
## $ Series_Complete_Janssen_12Plus         <dbl> 290187, 114760, 50796, 11759, 2~
## $ Series_Complete_Moderna_12Plus         <dbl> 1362821, 597774, 225749, 29566,~
## $ Series_Complete_Pfizer_12Plus          <dbl> 1978190, 880660, 278400, 1129, ~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 1883, 549, 370, 2, 9609, 581, 7~
## $ Series_Complete_Janssen_18Plus         <dbl> 288996, 114657, 50744, 11744, 2~
## $ Series_Complete_Moderna_18Plus         <dbl> 1359133, 597429, 225649, 29562,~
## $ Series_Complete_Pfizer_18Plus          <dbl> 1729411, 772654, 248194, 177, 1~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 1820, 480, 363, 2, 9529, 540, 7~
## $ Series_Complete_Janssen_65Plus         <dbl> 25892, 17852, 9692, 1064, 34549~
## $ Series_Complete_Moderna_65Plus         <dbl> 354554, 198118, 82734, 2310, 46~
## $ Series_Complete_Pfizer_65Plus          <dbl> 361502, 199350, 79772, 8, 43133~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 684, 235, 184, 0, 5161, 264, 35~
## $ Additional_Doses                       <dbl> 1040424, 372165, 166815, 1243, ~
## $ Additional_Doses_Vax_Pct               <dbl> 28.5, 23.3, 30.0, 2.9, 24.5, 15~
## $ Additional_Doses_18Plus                <dbl> 1039133, 371717, 166591, 1240, ~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 30.7, 25.0, 31.7, 3.0, 25.8, 16~
## $ Additional_Doses_50Plus                <dbl> 709407, 285860, 130719, 527, 65~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 45.2, 35.7, 42.5, 4.2, 36.1, 22~
## $ Additional_Doses_65Plus                <dbl> 441998, 195358, 91429, 161, 448~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 59.5, 47.0, 53.0, 4.8, 48.0, 29~
## $ Additional_Doses_Moderna               <dbl> 471885, 162870, 75401, 1197, 34~
## $ Additional_Doses_Pfizer                <dbl> 554745, 204374, 88538, 10, 4721~
## $ Additional_Doses_Janssen               <dbl> 13664, 4833, 2660, 36, 10712, 4~
## $ Additional_Doses_Unk_Manuf             <dbl> 130, 88, 216, 0, 1676, 28, 628,~
## $ Administered_Dose1_Recip_5Plus         <dbl> 4129531, 1936736, 641376, 47739~
## $ Administered_Dose1_Recip_5PlusPop_Pct  <dbl> 76.1, 71.0, 63.7, 51.4, 60.6, 8~
## $ Series_Complete_5Plus                  <dbl> 3655266, 1598570, 555960, 42461~
## $ Series_Complete_5PlusPop_Pct           <dbl> 67.4, 58.6, 55.2, 45.7, 52.8, 6~
## $ Administered_5Plus                     <dbl> 8678154, 3728366, 1333834, 8004~
## $ Admin_Per_100k_5Plus                   <dbl> 159921, 136671, 132374, 86235, ~
## $ Distributed_Per_100k_5Plus             <dbl> 189148, 177457, 164945, 112927,~
## $ Series_Complete_Moderna_5Plus          <dbl> 1362832, 597775, 225752, 29567,~
## $ Series_Complete_Pfizer_5Plus           <dbl> 2000356, 885475, 279041, 1129, ~
## $ Series_Complete_Janssen_5Plus          <dbl> 290192, 114770, 50797, 11763, 2~
## $ Series_Complete_Unk_Manuf_5Plus        <dbl> 1886, 550, 370, 2, 9613, 582, 7~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.34e+10    2.50e+8   4.83e+7 767724       40120    
## 2 after   1.34e+10    2.48e+8   4.81e+7 764111       34680    
## 3 pctchg  4.37e- 3    4.23e-3   4.45e-3      0.00471     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 34,680
## Columns: 6
## $ date       <date> 2021-04-01, 2021-05-31, 2020-06-13, 2021-02-02, 2021-09-19~
## $ state      <chr> "CA", "CA", "AL", "IL", "DE", "WI", "NC", "ND", "AL", "AL",~
## $ tot_cases  <dbl> 3570660, 3685032, 25331, 1130917, 128253, 25480, 14513, 660~
## $ tot_deaths <dbl> 58090, 62011, 1062, 21336, 1920, 700, 589, 103, 41, 14952, ~
## $ new_cases  <dbl> 2234, 644, 959, 2304, 450, 185, 467, 133, 121, 1558, 899, 6~
## $ new_deaths <dbl> 154, 5, 8, 63, 0, 2, 19, 0, 9, 46, 16, 66, 8, 165, 33, 0, 1~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.67e+7    3.06e+7 686791      34355     
## 2 after  3.66e+7    3.05e+7 672548      33003     
## 3 pctchg 5.03e-3    4.87e-3      0.0207     0.0394
## 
## 
## Processed for cdcHosp:
## Rows: 33,003
## Columns: 5
## $ date       <date> 2020-10-14, 2020-10-14, 2020-10-11, 2020-10-10, 2020-10-09~
## $ state      <chr> "ID", "NE", "DC", "NH", "HI", "ID", "KS", "NH", "KY", "NV",~
## $ inp        <dbl> 221, 376, 154, 45, 110, 194, 474, 52, 623, 501, 1213, 302, ~
## $ hosp_adult <dbl> 219, 367, 136, 44, 108, 194, 454, 52, 611, 500, 1180, 291, ~
## $ hosp_ped   <dbl> 2, 9, 18, 1, 2, 0, 5, 0, 12, 1, 32, 6, 9, 6, 1, 33, 8, 9, 2~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65  vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>        <dbl>    <dbl>       <dbl>
## 1 before 1.83e+11 7.97e+10 709132.    2.25e+10 1150103.     7.60e+10  858768.   
## 2 after  8.74e+10 3.85e+10 596524.    1.09e+10 1041832.     3.67e+10  731409.   
## 3 pctchg 5.22e- 1 5.16e- 1      0.159 5.16e- 1       0.0941 5.17e- 1       0.148
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 18,054
## Columns: 9
## $ date        <date> 2021-12-02, 2021-12-02, 2021-12-02, 2021-12-02, 2021-12-0~
## $ state       <chr> "CO", "KS", "MT", "TN", "PA", "IL", "HI", "ID", "MS", "FL"~
## $ vxa         <dbl> 8678461, 3728475, 1333956, 8234345, 18442499, 17941198, 20~
## $ vxc         <dbl> 3655321, 1598588, 555986, 3392571, 7513481, 7805286, 86708~
## $ vxcpoppct   <dbl> 63.5, 54.9, 52.0, 49.7, 58.7, 61.6, 61.2, 45.3, 47.1, 61.6~
## $ vxcgte65    <dbl> 742632, 415555, 172382, 934141, 2036584, 1759738, 238119, ~
## $ vxcgte65pct <dbl> 88.2, 87.4, 83.5, 81.7, 85.1, 86.1, 88.7, 84.0, 81.1, 87.9~
## $ vxcgte18    <dbl> 3379360, 1485220, 524950, 3216071, 7061682, 7205279, 81111~
## $ vxcgte18pct <dbl> 75.1, 67.1, 62.5, 60.5, 69.5, 73.1, 72.7, 60.4, 58.0, 72.4~
## 
## Integrated per capita data file:
## Rows: 34,893
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_211202, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_211202.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The latest data are downloaded and processed:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_211224.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_211224.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_211224.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_211202")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_211202")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_211202")$dfRaw$vax
                    )

cdc_daily_211224 <- readRunCDCDaily(thruLabel="Dec 23, 2021", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_211224.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 21
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta   pctDelta
## 1 2021-11-28 new_deaths      180      131       49 0.31511254
## 2 2021-11-27 new_deaths      207      153       54 0.30000000
## 3 2021-11-21 new_deaths      174      143       31 0.19558360
## 4 2021-11-25 new_deaths      453      416       37 0.08515535
## 5 2021-11-20 new_deaths      358      331       27 0.07837446
## 6 2021-11-14 new_deaths      214      198       16 0.07766990

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     KY tot_deaths  3131235  3044811    86424 0.027986838
## 2     MP tot_deaths     1266     1263        3 0.002372479
## 3     AL tot_deaths  4865040  4858536     6504 0.001337779
## 4     MP  tot_cases    87102    84054     3048 0.035616630
## 5     KY new_deaths    11768    10987      781 0.068644254
## 6     AL new_deaths    16309    16157      152 0.009363642
## 7     NC new_deaths    18915    18776      139 0.007375766
## 8     FL new_deaths    62080    61630      450 0.007275079
## 9     MP  new_cases      855      395      460 0.736000000
## 10    KY  new_cases   792201   789102     3099 0.003919552
## 11    NC  new_cases  1539610  1537044     2566 0.001668046
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 42,060
## Columns: 15
## $ date           <date> 2021-12-01, 2021-04-01, 2021-05-31, 2020-12-08, 2021-0~
## $ state          <chr> "ND", "CA", "CA", "AL", "IL", "DE", "WI", "NC", "ND", "~
## $ tot_cases      <dbl> 163565, 3570660, 3685032, 277175, 1130917, 128253, 2548~
## $ conf_cases     <dbl> 135705, 3570660, 3685032, 231203, 1130917, 117969, 2293~
## $ prob_cases     <dbl> 27860, 0, 0, 45972, 0, 10284, 2548, 4922, 0, NA, NA, NA~
## $ new_cases      <dbl> 589, 2234, 644, 3513, 2304, 450, 185, 1801, 133, 15, 17~
## $ pnew_case      <dbl> 220, 0, 0, 921, 0, 36, 11, 114, 0, 0, 0, 0, NA, 0, 94, ~
## $ tot_deaths     <dbl> 1907, 58090, 62011, 5729, 21336, 1920, 700, 3656, 103, ~
## $ conf_death     <dbl> NA, 58090, 62011, 4818, 19306, 1756, 694, 3618, NA, NA,~
## $ prob_death     <dbl> NA, 0, 0, 911, 2030, 164, 6, 38, NA, NA, NA, 157, NA, 1~
## $ new_deaths     <dbl> 9, 154, 5, 55, 63, 0, 2, 25, 0, 0, -1, 7, 0, 0, 8, 165,~
## $ pnew_death     <dbl> 0, 0, 0, 10, 16, 0, 0, 1, 0, 0, 0, 0, NA, 0, 0, 0, 0, -~
## $ created_at     <chr> "12/02/2021 02:35:20 PM", "04/03/2021 12:00:00 AM", "06~
## $ consent_cases  <chr> "Agree", "Agree", "Agree", "Agree", "Agree", "Agree", "~
## $ consent_deaths <chr> "Not agree", "Agree", "Agree", "Agree", "Agree", "Agree~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_211224.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 21
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state       name newValue refValue absDelta    pctDelta
## 1     KS        inp   274294   273824      470 0.001714959
## 2     ME   hosp_ped      781      733       48 0.063408190
## 3     KS   hosp_ped     2947     2798      149 0.051871192
## 4     NV   hosp_ped     2998     3083       85 0.027955928
## 5     DE   hosp_ped     2747     2813       66 0.023741007
## 6     SC   hosp_ped     5316     5441      125 0.023240680
## 7     VA   hosp_ped    10072    10229      157 0.015467218
## 8     ID   hosp_ped     2261     2295       34 0.014925373
## 9     TN   hosp_ped    13050    12875      175 0.013500482
## 10    MA   hosp_ped     6271     6187       84 0.013485311
## 11    NJ   hosp_ped    11368    11519      151 0.013195264
## 12    AR   hosp_ped     8372     8448       76 0.009036861
## 13    AZ   hosp_ped    17671    17524      147 0.008353459
## 14    WV   hosp_ped     3485     3509       24 0.006863025
## 15    CO   hosp_ped    14015    13924       91 0.006514192
## 16    IN   hosp_ped    11243    11311       68 0.006029973
## 17    NM   hosp_ped     4590     4564       26 0.005680577
## 18    WY   hosp_ped      535      538        3 0.005591799
## 19    VT   hosp_ped      184      185        1 0.005420054
## 20    AL   hosp_ped    13252    13323       71 0.005343368
## 21    SD   hosp_ped     3048     3033       15 0.004933399
## 22    UT   hosp_ped     4886     4908       22 0.004492546
## 23    KY   hosp_ped    11608    11557       51 0.004403194
## 24    MS   hosp_ped     7227     7199       28 0.003881880
## 25    IA   hosp_ped     4386     4376       10 0.002282584
## 26    PA   hosp_ped    31152    31221       69 0.002212496
## 27    MO   hosp_ped    24222    24273       51 0.002103310
## 28    NH   hosp_ped      481      482        1 0.002076843
## 29    HI   hosp_ped     1445     1448        3 0.002073972
## 30    FL   hosp_ped    70884    70741      143 0.002019417
## 31    PR   hosp_ped    14228    14200       28 0.001969889
## 32    TX   hosp_ped    69942    69819      123 0.001760148
## 33    WI   hosp_ped     6240     6233        7 0.001122424
## 34    KS hosp_adult   247830   247511      319 0.001288002
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 35,489
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_211224.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 21
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 24,280
## Columns: 80
## $ date                                   <date> 2021-12-23, 2021-12-23, 2021-1~
## $ MMWR_week                              <dbl> 51, 51, 51, 51, 51, 51, 51, 51,~
## $ state                                  <chr> "AK", "SC", "US", "NJ", "UT", "~
## $ Distributed                            <dbl> 1322225, 8828335, 611897975, 18~
## $ Distributed_Janssen                    <dbl> 83100, 435600, 29391500, 894100~
## $ Distributed_Moderna                    <dbl> 506560, 3506920, 222509200, 658~
## $ Distributed_Pfizer                     <dbl> 732565, 4885815, 359997275, 110~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 180744, 171467, 184302, 208115,~
## $ Distributed_Per_100k_12Plus            <dbl> 217158, 199737, 215822, 242639,~
## $ Distributed_Per_100k_18Plus            <dbl> 239724, 218657, 236931, 266219,~
## $ Distributed_Per_100k_65Plus            <dbl> 1443670, 942168, 1116770, 12527~
## $ vxa                                    <dbl> 1015137, 6623650, 500222330, 14~
## $ Administered_12Plus                    <dbl> 989664, 6538665, 489911859, 143~
## $ Administered_18Plus                    <dbl> 925534, 6212540, 460223551, 134~
## $ Administered_65Plus                    <dbl> 205343, 2130888, 130509675, 347~
## $ Administered_Janssen                   <dbl> 40794, 215367, 17501026, 525052~
## $ Administered_Moderna                   <dbl> 395015, 2600706, 190891698, 563~
## $ Administered_Pfizer                    <dbl> 578479, 3805535, 291318945, 852~
## $ Administered_Unk_Manuf                 <dbl> 849, 2042, 510661, 907, 295, 13~
## $ Admin_Per_100k                         <dbl> 138766, 128647, 150665, 165339,~
## $ Admin_Per_100k_12Plus                  <dbl> 162539, 147934, 172796, 188596,~
## $ Admin_Per_100k_18Plus                  <dbl> 167802, 153870, 178202, 193386,~
## $ Admin_Per_100k_65Plus                  <dbl> 224203, 227410, 238191, 235477,~
## $ Recip_Administered                     <dbl> 1013631, 6599301, 500222330, 15~
## $ Administered_Dose1_Recip               <dbl> 473411, 3208049, 241520561, 735~
## $ Administered_Dose1_Pop_Pct             <dbl> 64.7, 62.3, 72.7, 82.8, 66.9, 7~
## $ Administered_Dose1_Recip_12Plus        <dbl> 456849, 3152140, 235109931, 715~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 75.0, 71.3, 82.9, 93.9, 79.5, 8~
## $ Administered_Dose1_Recip_18Plus        <dbl> 423349, 2975205, 219232193, 664~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 76.8, 73.7, 84.9, 95.0, 82.0, 8~
## $ Administered_Dose1_Recip_65Plus        <dbl> 85187, 924673, 55658469, 155410~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 93.0, 95.0, 95.0, 95.0, 95.0, 9~
## $ vxc                                    <dbl> 410287, 2721525, 204740321, 622~
## $ vxcpoppct                              <dbl> 56.1, 52.9, 61.7, 70.1, 58.4, 5~
## $ Series_Complete_12Plus                 <dbl> 401419, 2689999, 200881586, 610~
## $ Series_Complete_12PlusPop_Pct          <dbl> 65.9, 60.9, 70.9, 80.2, 70.4, 6~
## $ vxcgte18                               <dbl> 372484, 2540559, 187461696, 566~
## $ vxcgte18pct                            <dbl> 67.5, 62.9, 72.6, 81.6, 72.7, 6~
## $ vxcgte65                               <dbl> 77057, 796345, 47915719, 132439~
## $ vxcgte65pct                            <dbl> 84.1, 85.0, 87.5, 89.8, 90.1, 9~
## $ Series_Complete_Janssen                <dbl> 36800, 195966, 16265233, 489870~
## $ Series_Complete_Moderna                <dbl> 150339, 995798, 73147737, 22128~
## $ Series_Complete_Pfizer                 <dbl> 223048, 1529419, 115189845, 352~
## $ Series_Complete_Unk_Manuf              <dbl> 100, 342, 137506, 392, 9, 30, 5~
## $ Series_Complete_Janssen_12Plus         <dbl> 36796, 195922, 16260793, 489790~
## $ Series_Complete_Moderna_12Plus         <dbl> 150334, 995686, 73142638, 22127~
## $ Series_Complete_Pfizer_12Plus          <dbl> 214189, 1498049, 111341322, 340~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 100, 342, 136833, 391, 9, 30, 5~
## $ Series_Complete_Janssen_18Plus         <dbl> 36657, 195368, 16235127, 489546~
## $ Series_Complete_Moderna_18Plus         <dbl> 149942, 993747, 73062889, 22121~
## $ Series_Complete_Pfizer_18Plus          <dbl> 185791, 1351104, 98030208, 2966~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 94, 340, 133472, 372, 9, 30, 56~
## $ Series_Complete_Janssen_65Plus         <dbl> 3475, 30466, 2308213, 90977, 16~
## $ Series_Complete_Moderna_65Plus         <dbl> 42431, 340254, 22853608, 616897~
## $ Series_Complete_Pfizer_65Plus          <dbl> 31112, 425424, 22695193, 616389~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 39, 201, 58705, 136, 1, 20, 310~
## $ Additional_Doses                       <dbl> 136704, 798606, 64475171, 19601~
## $ Additional_Doses_Vax_Pct               <dbl> 33.3, 29.3, 31.5, 31.5, 27.9, 3~
## $ Additional_Doses_18Plus                <dbl> 135787, 796080, 64192194, 19496~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 36.5, 31.3, 34.2, 34.4, 31.4, 3~
## $ Additional_Doses_50Plus                <dbl> 89008, 633195, 45118229, 133206~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 51.1, 42.3, 46.2, 45.9, 47.8, 4~
## $ Additional_Doses_65Plus                <dbl> 48410, 422282, 27104857, 741134~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 62.8, 53.0, 56.6, 56.0, 60.0, 5~
## $ Additional_Doses_Moderna               <dbl> 62743, 338668, 28709418, 883192~
## $ Additional_Doses_Pfizer                <dbl> 72204, 443362, 34759759, 103482~
## $ Additional_Doses_Janssen               <dbl> 1739, 16126, 991941, 42146, 751~
## $ Additional_Doses_Unk_Manuf             <dbl> 18, 450, 14053, 18, 1, 8, 10, 5~
## $ Administered_Dose1_Recip_5Plus         <dbl> 473349, 3206908, 241480397, 735~
## $ Administered_Dose1_Recip_5PlusPop_Pct  <dbl> 69.6, 66.0, 77.3, 87.9, 72.5, 7~
## $ Series_Complete_5Plus                  <dbl> 410274, 2720990, 204730406, 622~
## $ Series_Complete_5PlusPop_Pct           <dbl> 60.3, 56.0, 65.6, 74.4, 63.2, 6~
## $ Administered_5Plus                     <dbl> 1015062, 6621955, 500174369, 14~
## $ Admin_Per_100k_5Plus                   <dbl> 149172, 136359, 160176, 175499,~
## $ Distributed_Per_100k_5Plus             <dbl> 194312, 181793, 195955, 220916,~
## $ Series_Complete_Moderna_5Plus          <dbl> 150336, 995723, 73144600, 22127~
## $ Series_Complete_Pfizer_5Plus           <dbl> 223042, 1529001, 115186044, 352~
## $ Series_Complete_Janssen_5Plus          <dbl> 36796, 195924, 16262294, 489818~
## $ Series_Complete_Unk_Manuf_5Plus        <dbl> 100, 342, 137468, 392, 9, 30, 5~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.45e+10    2.66e+8   5.12e+7 793663       41359    
## 2 after   1.44e+10    2.65e+8   5.10e+7 790023       35751    
## 3 pctchg  4.37e- 3    4.25e-3   4.63e-3      0.00459     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 35,751
## Columns: 6
## $ date       <date> 2021-12-01, 2021-04-01, 2021-05-31, 2020-12-08, 2021-02-02~
## $ state      <chr> "ND", "CA", "CA", "AL", "IL", "DE", "WI", "NC", "ND", "NE",~
## $ tot_cases  <dbl> 163565, 3570660, 3685032, 277175, 1130917, 128253, 25480, 2~
## $ tot_deaths <dbl> 1907, 58090, 62011, 5729, 21336, 1920, 700, 3656, 103, 282,~
## $ new_cases  <dbl> 589, 2234, 644, 3513, 2304, 450, 185, 1801, 133, 179, 798, ~
## $ new_deaths <dbl> 9, 154, 5, 55, 63, 0, 2, 25, 0, -1, 7, 0, 0, 8, 165, 0, 41,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.81e+7    3.20e+7 721869      35489     
## 2 after  3.80e+7    3.19e+7 707444      34074     
## 3 pctchg 4.88e-3    4.69e-3      0.0200     0.0399
## 
## 
## Processed for cdcHosp:
## Rows: 34,074
## Columns: 5
## $ date       <date> 2020-10-16, 2020-10-14, 2020-10-11, 2020-10-10, 2020-10-09~
## $ state      <chr> "NH", "HI", "HI", "NM", "HI", "DC", "KS", "NH", "LA", "MO",~
## $ inp        <dbl> 38, 111, 99, 184, 110, 166, 474, 52, 549, 1208, 1185, 156, ~
## $ hosp_adult <dbl> 38, 111, 99, 173, 108, 149, 454, 52, 537, 1174, 1143, 143, ~
## $ hosp_ped   <dbl> 0, 0, 0, 11, 2, 17, 5, 0, 12, 32, 41, 13, 0, 17, 1, 0, 2, 2~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65  vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>        <dbl>    <dbl>       <dbl>
## 1 before 2.03e+11 8.83e+10 785079.    2.46e+10 1258189.     8.39e+10  948625.   
## 2 after  9.74e+10 4.27e+10 660214.    1.19e+10 1135392.     4.06e+10  806974.   
## 3 pctchg 5.21e- 1 5.17e- 1      0.159 5.16e- 1       0.0976 5.17e- 1       0.149
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 19,125
## Columns: 9
## $ date        <date> 2021-12-23, 2021-12-23, 2021-12-23, 2021-12-23, 2021-12-2~
## $ state       <chr> "AK", "SC", "NJ", "UT", "SD", "DE", "MI", "MT", "WI", "PA"~
## $ vxa         <dbl> 1015137, 6623650, 14685687, 4444635, 1243823, 1564474, 137~
## $ vxc         <dbl> 410287, 2721525, 6226479, 1870704, 501708, 621891, 5644292~
## $ vxcpoppct   <dbl> 56.1, 52.9, 70.1, 58.4, 56.7, 63.9, 56.5, 53.8, 61.7, 63.5~
## $ vxcgte65    <dbl> 77057, 796345, 1324399, 329535, 138881, 175050, 1522802, 1~
## $ vxcgte65pct <dbl> 84.1, 85.0, 89.8, 90.1, 91.4, 92.7, 86.3, 84.1, 93.3, 90.8~
## $ vxcgte18    <dbl> 372484, 2540559, 5668559, 1654379, 461584, 573855, 5209125~
## $ vxcgte18pct <dbl> 67.5, 62.9, 81.6, 72.7, 69.1, 74.5, 66.4, 63.5, 72.3, 73.8~
## 
## Integrated per capita data file:
## Rows: 35,964
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_211224, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_211224.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

Code is also written to download the latest data by individual hospital:

indivHospFile <- "./RInputFiles/Coronavirus/HHS_Hospital_20211225.csv"

# Download the file
fileDownload(indivHospFile, url="https://healthdata.gov/api/views/anag-cw7u/rows.csv?accessType=DOWNLOAD")

# Read the file and glimpse
indivHosp_20211225 <- fileRead(indivHospFile)
glimpse(indivHosp_20211225)

# Save in RDS format for future processing
saveToRDS(indivHosp_20211225, ovrWriteError=FALSE)

Checks are run on some of the key fields in the data, including:

indivHosp_20211225 <- readFromRDS("indivHosp_20211225")

# Hospital demographic data
indivHosp_20211225 %>% count(hospital_subtype)
## # A tibble: 4 x 2
##   hospital_subtype               n
##   <chr>                      <int>
## 1 Childrens Hospitals         6757
## 2 Critical Access Hospitals  96111
## 3 Long Term                  24724
## 4 Short Term                232151
indivHosp_20211225 %>% count(state) %>% filter(!(state %in% c(state.abb, "DC")))
## # A tibble: 5 x 2
##   state     n
##   <chr> <int>
## 1 AS       17
## 2 GU      144
## 3 MP       72
## 4 PR     3976
## 5 VI      144
# Hospital beds average
hhsMapper <- c("total_beds_7_day_avg"="total_beds", 
               "all_adult_hospital_beds_7_day_avg"="adult_beds", 
               "all_adult_hospital_inpatient_bed_occupied_7_day_avg"="adult_beds_occupied", 
               "total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg"="adult_beds_covid", 
               "inpatient_beds_7_day_avg"="inpatient_beds", 
               "total_icu_beds_7_day_avg"="icu_beds", 
               "icu_beds_used_7_day_avg"="icu_beds_occupied", 
               "staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg"="adult_icu_covid"
               )

# Histograms by metric
indivHosp_20211225 %>%
    select(names(hhsMapper)) %>%
    pivot_longer(-c()) %>%
    ggplot(aes(x=value)) + 
    geom_histogram(fill="lightblue") + 
    facet_wrap(~name, scales="free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 22873 rows containing non-finite values (stat_bin).

# Histograms by metric, excluding NA and -999999
indivHosp_20211225 %>%
    select(names(hhsMapper)) %>%
    pivot_longer(-c()) %>%
    filter(!is.na(value), value != -999999) %>%
    ggplot(aes(x=value)) + 
    geom_histogram(fill="lightblue") + 
    facet_wrap(~hhsMapper[name], scales="free")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

# Key metrics for a select hospital
set.seed(2112261542)
keyHosp <- indivHosp_20211225 %>% pull(hospital_pk) %>% sample(1)
keyHospName <- indivHosp_20211225 %>% 
    filter(hospital_pk %in% all_of(keyHosp), collection_week==max(collection_week)) %>%
    mutate(useName=paste0(hospital_name, " (code: ", keyHosp, ") ",city, ", ", state, " ", zip)) %>%
    pull(useName)

indivHosp_20211225 %>%
    filter(hospital_pk %in% all_of(keyHosp)) %>%
    select(date=collection_week, names(hhsMapper)) %>%
    pivot_longer(-c(date)) %>%
    filter(!is.na(value), value != -999999) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_line() + 
    facet_wrap(~hhsMapper[name], scales="free_y") + 
    lims(y=c(0, NA)) + 
    labs(x=NULL, y="Average weekly value", title=keyHospName)

The key hospital is plotted for similar metrics:

# Adult Beds
indivHosp_20211225 %>%
    filter(hospital_pk %in% all_of(keyHosp)) %>%
    select(date=collection_week, names(hhsMapper)[1:4]) %>%
    colRenamer(vecRename=hhsMapper[1:4]) %>%
    pivot_longer(-c(date)) %>%
    filter(!is.na(value), value != -999999) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_col(data=~filter(., !(name %in% c("total_beds", "adult_beds"))), aes(fill=name), position="identity") + 
    geom_line(data=~filter(., name %in% c("total_beds", "adult_beds")), 
              aes(group=name, color=name), 
              size=1.5
              ) + 
    lims(y=c(0, NA)) + 
    labs(x=NULL, y="Average weekly value", title=keyHospName, subtitle="Adult beds") + 
    scale_color_manual("Capacity", values=c("adult_beds"="black", "total_beds"="green")) + 
    scale_fill_manual("Occupied", values=c("adult_beds_covid"="red", "adult_beds_occupied"="lightblue"))

# Adult ICU Beds
indivHosp_20211225 %>%
    filter(hospital_pk %in% all_of(keyHosp)) %>%
    select(date=collection_week, names(hhsMapper)[6:8]) %>%
    colRenamer(vecRename=hhsMapper[6:8]) %>%
    pivot_longer(-c(date)) %>%
    filter(!is.na(value), value != -999999) %>%
    ggplot(aes(x=date, y=value)) + 
    geom_col(data=~filter(., !(name %in% c("icu_beds"))), aes(fill=name), position="identity") + 
    geom_line(data=~filter(., name %in% c("icu_beds")), aes(group=name, color=name), size=1.5) + 
    lims(y=c(0, NA)) + 
    labs(x=NULL, y="Average weekly value", title=keyHospName, subtitle="ICU beds") + 
    scale_color_manual("Capacity", values=c("icu_beds"="black")) + 
    scale_fill_manual("Occupied", values=c("adult_icu_covid"="red", "icu_beds_occupied"="lightblue"))

The process is converted to functional form:

plotHospitalUtilization <- function(df, 
                                    keyHosp=NULL, 
                                    plotTitle=NULL,
                                    seed=2112261542, 
                                    varMap=hhsMapper, 
                                    createFacets=TRUE,
                                    p2List=list("Adult Beds"=list("colsPlot"=c("adult_beds_occupied"="lightblue", 
                                                                               "adult_beds_covid"="red"
                                                                               ), 
                                                                  "linesPlot"=c("adult_beds"="black", 
                                                                                "total_beds"="green"
                                                                                )
                                                                  ), 
                                                "ICU Beds"=list("colsPlot"=c("icu_beds_occupied"="lightblue", 
                                                                             "adult_icu_covid"="red"
                                                                             ), 
                                                                "linesPlot"=c("icu_beds"="black")
                                                                )
                                                ),
                                    returnData=FALSE
                                    ) {
    
    # FUNCTION ARGUMENTS:
    # df: file containing hospital utilization data
    # keyHosp: character vector of hospital_pk to use (NULL means select one at random using seed)
    # plotTitle: title to use for plots (NULL means use a default based on keyHosp)
    # seed: random seed to use for selecting a hospital
    # varMap: character mapping file of format c("variable name"="plotting facet name")
    # createFacets: boolean, should the facetted plots be create?
    # returnData: boolean, should plot data be returned?
    
    # Sample a keyHosp if not provided
    if(is.null(keyHosp)) {
        set.seed(seed)
        keyHosp <- df %>% 
            pull(hospital_pk) %>% 
            sample(1)        
    }
    
    # Get plotTitle if not provided
    if(is.null(plotTitle)) {
        if(length(keyHosp) > 1) plotTitle <- "Multiple hospitals combined"
        else {
            plotTitle <- df %>% 
                filter(hospital_pk %in% all_of(keyHosp), collection_week==max(collection_week)) %>%
                mutate(useName=paste0(hospital_name, " (code: ", keyHosp, ") ",city, ", ", state, " ", zip)) %>%
                pull(useName)
        }
    }

    # Create key plot data
    p1Data <- df %>%
        filter(hospital_pk %in% all_of(keyHosp)) %>%
        select(date=collection_week, names(varMap)) %>%
        colRenamer(vecRename=varMap) %>%
        pivot_longer(-c(date)) %>%
        filter(!is.na(value), value != -999999) %>%
        group_by(date, name) %>%
        summarize(value=sum(value, na.rm=TRUE), n=n(), .groups="drop")
    
    # Create the facetted plots if requested
    if(isTRUE(createFacets)) {
        # Create the key plot
        p1 <- p1Data %>%
            ggplot(aes(x=date, y=value)) + 
            geom_line() + 
            facet_wrap(~name, scales="free_y") + 
            lims(y=c(0, NA)) + 
            labs(x=NULL, y="Average weekly value", title=plotTitle)
        print(p1)
    }
    
    # Create the stacked bar plots
    for(plotType in names(p2List)) {
    
        # Create the base plot
        p2 <- ggplot(data=p1Data, aes(x=date, y=value))
        
        # Add the columns
        for(vCol in names(p2List[[plotType]][["colsPlot"]])) {
            p2 <- p2 + geom_col(data=mutate(filter(p1Data, name %in% vCol), fill=vCol), aes(fill=fill))
        }
        
        # Add the lines
        p2 <- p2 + geom_line(data=filter(p1Data, name %in% names(p2List[[plotType]][["linesPlot"]])), 
                             aes(group=name, color=name), 
                             size=1.5
                             )
        
        # Add the limits, labels, and scales
        p2 <- p2 + 
            lims(y=c(0, NA)) + 
            labs(x=NULL, y="Average weekly value", title=plotTitle, subtitle=plotType) +
            scale_color_manual("Capacity", values=p2List[[plotType]][["linesPlot"]]) + 
            scale_fill_manual("Occupied", values=p2List[[plotType]][["colsPlot"]])
        
        # Print the plot
        print(p2)
        
    }
    
    # Return the data if requested
    if(isTRUE(returnData)) return(p1Data)
    
}

# Random hospital selection, full plots
plotHospitalUtilization(indivHosp_20211225)

plotHospitalUtilization(indivHosp_20211225, seed=2112281733)

# Random hospital selection, one plot or data
plotHospitalUtilization(indivHosp_20211225, createFacets=FALSE)

plotHospitalUtilization(indivHosp_20211225, p2List=list())

plotHospitalUtilization(indivHosp_20211225, createFacets=FALSE, p2List=list(), returnData=TRUE)
## # A tibble: 494 x 4
##    date       name                value     n
##    <date>     <chr>               <dbl> <int>
##  1 2020-07-31 adult_beds           76       1
##  2 2020-07-31 adult_beds_occupied  57.4     1
##  3 2020-07-31 icu_beds             16       1
##  4 2020-07-31 icu_beds_occupied    12.6     1
##  5 2020-07-31 inpatient_beds       76       1
##  6 2020-07-31 total_beds           76       1
##  7 2020-08-07 adult_beds           74.6     1
##  8 2020-08-07 adult_beds_occupied  51.9     1
##  9 2020-08-07 icu_beds             16       1
## 10 2020-08-07 icu_beds_occupied    12.7     1
## # ... with 484 more rows
# Combination of hospitals, full plots
indivHosp_20211225 %>% 
    filter(state=="FL", collection_week==max(collection_week)) %>% 
    pull(hospital_pk) %>%
    plotHospitalUtilization(df=indivHosp_20211225, keyHosp=., plotTitle="Florida Hospitals Summed")

The process to download and read data is converted to functional form:

# Hospital beds average
hhsMapper <- c("total_beds_7_day_avg"="total_beds", 
               "all_adult_hospital_beds_7_day_avg"="adult_beds", 
               "all_adult_hospital_inpatient_bed_occupied_7_day_avg"="adult_beds_occupied", 
               "total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg"="adult_beds_covid", 
               "inpatient_beds_7_day_avg"="inpatient_beds", 
               "total_icu_beds_7_day_avg"="icu_beds", 
               "icu_beds_used_7_day_avg"="icu_beds_occupied", 
               "staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg"="adult_icu_covid"
               )

downloadReadHospitalData <- function(loc, 
                                     url="https://healthdata.gov/api/views/anag-cw7u/rows.csv?accessType=DOWNLOAD",
                                     ovrWrite=FALSE, 
                                     mapper=hhsMapper
                                     ) {
    
    # FUNCTION ARGUMENTS:
    # loc: location for the downloaded data
    # url location for downloading data
    # ovrWrite: boolean, if loc exists, should it be overwritten?
    # mapper: character vector of form c("variable"="formatted name") of variables to run histograms for
    
    # Check if the file exists, download if appropriate
    tempDownload <- function(x=loc, y=url, z=ovrWrite) {
    
        if(file.exists(x)) {
            cat("\nFile", x, "already exists\n")
            if(!isTRUE(z)) {
                cat("File will not be downloaded since ovrWrite is not TRUE\n")
                return()
            }
        }
        
        # Download the file
        fileDownload(x, url=y, ovrWrite=z)
        
    }
    
    tempDownload()

    # Read the file and glimpse
    df <- fileRead(loc)
    glimpse(df)

    # Basic count checks
    cat("\nHospital Subtype Counts:\n")
    df %>% count(hospital_subtype) %>% print()
    cat("\nRecords other than 50 states and DC\n")
    df %>% count(state) %>% filter(!(state %in% c(state.abb, "DC"))) %>% print()

    # Counts of less than 0, NA, and -999999
    cat("\nRecord types for key metrics\n")
    df %>%
        select(names(mapper)) %>%
        pivot_longer(-c()) %>%
        mutate(type=case_when(is.na(value) ~ "NA", 
                              value==-999999 ~ "Value -999999", 
                              value < 0 ~ "Negative", 
                              TRUE ~ "Positive"
                              )
               ) %>%
        count(name, type) %>%
        pivot_wider(name, names_from="type", values_from="n", values_fill=0) %>%
        group_by(name) %>%
        mutate(Total=sum(across(where(is.numeric)))) %>%
        ungroup() %>%
        print()
    
    # Basic Histograms (NA and -999999 are missing data)
    p1 <- df %>%
        select(names(mapper)) %>%
        pivot_longer(-c()) %>%
        filter(!is.na(value), value != -999999, value >= 0) %>%
        ggplot(aes(x=value/1000)) + 
        geom_histogram(fill="lightblue") + 
        scale_x_sqrt() +
        labs(x="Value (000s)", 
             y="# non-missing records", 
             title="Histogram for key metrics by record", 
             subtitle="Excludes values less than 0, as well as NA or -999999"
             ) +
        facet_wrap(~hhsMapper[name], scales="free")
    print(p1)
    
    # Return the file
    df
    
}

The process is run and cached for reduced processing time:

# Example using existing data
downloadReadHospitalData(loc="./RInputFiles/Coronavirus/HHS_Hospital_20211225.csv")
## 
## File ./RInputFiles/Coronavirus/HHS_Hospital_20211225.csv already exists
## File will not be downloaded since ovrWrite is not TRUE
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   hospital_pk = col_character(),
##   collection_week = col_date(format = ""),
##   state = col_character(),
##   ccn = col_character(),
##   hospital_name = col_character(),
##   address = col_character(),
##   city = col_character(),
##   zip = col_character(),
##   hospital_subtype = col_character(),
##   fips_code = col_character(),
##   is_metro_micro = col_logical(),
##   geocoded_hospital_address = col_character(),
##   hhs_ids = col_character(),
##   is_corrected = col_logical()
## )
## i Use `spec()` for the full column specifications.
## Rows: 359,743
## Columns: 106
## $ hospital_pk                                                                        <chr> ~
## $ collection_week                                                                    <date> ~
## $ state                                                                              <chr> ~
## $ ccn                                                                                <chr> ~
## $ hospital_name                                                                      <chr> ~
## $ address                                                                            <chr> ~
## $ city                                                                               <chr> ~
## $ zip                                                                                <chr> ~
## $ hospital_subtype                                                                   <chr> ~
## $ fips_code                                                                          <chr> ~
## $ is_metro_micro                                                                     <lgl> ~
## $ total_beds_7_day_avg                                                               <dbl> ~
## $ all_adult_hospital_beds_7_day_avg                                                  <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_avg                                        <dbl> ~
## $ inpatient_beds_used_7_day_avg                                                      <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_avg                                <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg          <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_avg                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg      <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg                    <dbl> ~
## $ inpatient_beds_7_day_avg                                                           <dbl> ~
## $ total_icu_beds_7_day_avg                                                           <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_avg                                             <dbl> ~
## $ icu_beds_used_7_day_avg                                                            <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_avg                                          <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg                 <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_avg                               <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_avg                          <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_avg                                         <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg                <dbl> ~
## $ total_beds_7_day_sum                                                               <dbl> ~
## $ all_adult_hospital_beds_7_day_sum                                                  <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_sum                                        <dbl> ~
## $ inpatient_beds_used_7_day_sum                                                      <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_sum                                <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum          <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_sum                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum      <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum                    <dbl> ~
## $ inpatient_beds_7_day_sum                                                           <dbl> ~
## $ total_icu_beds_7_day_sum                                                           <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_sum                                             <dbl> ~
## $ icu_beds_used_7_day_sum                                                            <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_sum                                          <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum                 <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_sum                               <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_sum                          <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_sum                                         <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum                <dbl> ~
## $ total_beds_7_day_coverage                                                          <dbl> ~
## $ all_adult_hospital_beds_7_day_coverage                                             <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_coverage                                   <dbl> ~
## $ inpatient_beds_used_7_day_coverage                                                 <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_coverage                           <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_coverage                   <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage               <dbl> ~
## $ inpatient_beds_7_day_coverage                                                      <dbl> ~
## $ total_icu_beds_7_day_coverage                                                      <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_coverage                                        <dbl> ~
## $ icu_beds_used_7_day_coverage                                                       <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_coverage                          <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_coverage                     <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_coverage                                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_7_day_sum                             <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_7_day_sum`                       <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_7_day_sum                     <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_7_day_sum                         <dbl> ~
## $ previous_day_covid_ED_visits_7_day_sum                                             <dbl> ~
## $ previous_day_admission_adult_covid_suspected_7_day_sum                             <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_7_day_sum`                       <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_7_day_sum                     <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_7_day_sum                         <dbl> ~
## $ previous_day_total_ED_visits_7_day_sum                                             <dbl> ~
## $ previous_day_admission_influenza_confirmed_7_day_sum                               <dbl> ~
## $ geocoded_hospital_address                                                          <chr> ~
## $ hhs_ids                                                                            <chr> ~
## $ previous_day_admission_adult_covid_confirmed_7_day_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_7_day_coverage                    <dbl> ~
## $ previous_day_admission_adult_covid_suspected_7_day_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_7_day_coverage                    <dbl> ~
## $ previous_week_personnel_covid_vaccinated_doses_administered_7_day                  <dbl> ~
## $ total_personnel_covid_vaccinated_doses_none_7_day                                  <dbl> ~
## $ total_personnel_covid_vaccinated_doses_one_7_day                                   <dbl> ~
## $ total_personnel_covid_vaccinated_doses_all_7_day                                   <dbl> ~
## $ previous_week_patients_covid_vaccinated_doses_one_7_day                            <dbl> ~
## $ previous_week_patients_covid_vaccinated_doses_all_7_day                            <dbl> ~
## $ is_corrected                                                                       <lgl> ~
## 
## Hospital Subtype Counts:
## # A tibble: 4 x 2
##   hospital_subtype               n
##   <chr>                      <int>
## 1 Childrens Hospitals         6757
## 2 Critical Access Hospitals  96111
## 3 Long Term                  24724
## 4 Short Term                232151
## 
## Records other than 50 states and DC
## # A tibble: 5 x 2
##   state     n
##   <chr> <int>
## 1 AS       17
## 2 GU      144
## 3 MP       72
## 4 PR     3976
## 5 VI      144
## 
## Record types for key metrics
## # A tibble: 8 x 6
##   name                             `NA` Positive `Value -999999` Negative  Total
##   <chr>                           <int>    <int>           <int>    <int>  <int>
## 1 all_adult_hospital_beds_7_day_~  6229   352869             645        0 359743
## 2 all_adult_hospital_inpatient_b~  3313   327037           29385        8 359743
## 3 icu_beds_used_7_day_avg          1644   314605           43487        7 359743
## 4 inpatient_beds_7_day_avg         1722   356603            1418        0 359743
## 5 staffed_icu_adult_patients_con~  4243   249411          106089        0 359743
## 6 total_adult_patients_hospitali~  2364   249154          108225        0 359743
## 7 total_beds_7_day_avg             1294   358116             333        0 359743
## 8 total_icu_beds_7_day_avg         2064   339859           17820        0 359743
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

## # A tibble: 359,743 x 106
##    hospital_pk collection_week state ccn    hospital_name   address  city  zip  
##    <chr>       <date>          <chr> <chr>  <chr>           <chr>    <chr> <chr>
##  1 670031      2021-12-10      TX    670031 ST LUKE'S PATI~ 4600 EA~ PASA~ 77505
##  2 061314      2020-07-31      CO    061314 MEMORIAL HOSPI~ 750 HOS~ CRAIG 81625
##  3 520034      2020-07-31      WI    520034 AURORA MEDICAL~ 5000 ME~ TWO ~ 54241
##  4 522008      2020-07-31      WI    522008 SELECT SPECIAL~ 801 BRA~ MADI~ 53715
##  5 050769      2020-07-31      CA    050769 HOAG ORTHOPEDI~ 16250 S~ IRVI~ 92618
##  6 501329      2020-08-07      WA    501329 PEACEHEALTH UN~ 2000 HO~ SEDR~ 98284
##  7 280134      2020-07-31      NE    280134 KEARNEY REGION~ 804 22N~ KEAR~ 68845
##  8 452034      2020-07-31      TX    452034 CORNERSTONE SP~ 4207 BU~ AUST~ 78756
##  9 330229      2020-07-31      NY    330229 BROOKS-TLC HOS~ 529 CEN~ DUNK~ 14048
## 10 451341      2020-08-07      TX    451341 HASKELL MEMORI~ 1 NORTH~ HASK~ 79521
## # ... with 359,733 more rows, and 98 more variables: hospital_subtype <chr>,
## #   fips_code <chr>, is_metro_micro <lgl>, total_beds_7_day_avg <dbl>,
## #   all_adult_hospital_beds_7_day_avg <dbl>,
## #   all_adult_hospital_inpatient_beds_7_day_avg <dbl>,
## #   inpatient_beds_used_7_day_avg <dbl>,
## #   all_adult_hospital_inpatient_bed_occupied_7_day_avg <dbl>,
## #   total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg <dbl>,
## #   total_adult_patients_hospitalized_confirmed_covid_7_day_avg <dbl>,
## #   total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg <dbl>,
## #   total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg <dbl>,
## #   inpatient_beds_7_day_avg <dbl>, total_icu_beds_7_day_avg <dbl>,
## #   total_staffed_adult_icu_beds_7_day_avg <dbl>,
## #   icu_beds_used_7_day_avg <dbl>,
## #   staffed_adult_icu_bed_occupancy_7_day_avg <dbl>,
## #   staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg <dbl>,
## #   staffed_icu_adult_patients_confirmed_covid_7_day_avg <dbl>,
## #   total_patients_hospitalized_confirmed_influenza_7_day_avg <dbl>,
## #   icu_patients_confirmed_influenza_7_day_avg <dbl>,
## #   total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg <dbl>,
## #   total_beds_7_day_sum <dbl>, all_adult_hospital_beds_7_day_sum <dbl>,
## #   all_adult_hospital_inpatient_beds_7_day_sum <dbl>,
## #   inpatient_beds_used_7_day_sum <dbl>,
## #   all_adult_hospital_inpatient_bed_occupied_7_day_sum <dbl>,
## #   total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum <dbl>,
## #   total_adult_patients_hospitalized_confirmed_covid_7_day_sum <dbl>,
## #   total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum <dbl>,
## #   total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum <dbl>,
## #   inpatient_beds_7_day_sum <dbl>, total_icu_beds_7_day_sum <dbl>,
## #   total_staffed_adult_icu_beds_7_day_sum <dbl>,
## #   icu_beds_used_7_day_sum <dbl>,
## #   staffed_adult_icu_bed_occupancy_7_day_sum <dbl>,
## #   staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum <dbl>,
## #   staffed_icu_adult_patients_confirmed_covid_7_day_sum <dbl>,
## #   total_patients_hospitalized_confirmed_influenza_7_day_sum <dbl>,
## #   icu_patients_confirmed_influenza_7_day_sum <dbl>,
## #   total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum <dbl>,
## #   total_beds_7_day_coverage <dbl>,
## #   all_adult_hospital_beds_7_day_coverage <dbl>,
## #   all_adult_hospital_inpatient_beds_7_day_coverage <dbl>,
## #   inpatient_beds_used_7_day_coverage <dbl>,
## #   all_adult_hospital_inpatient_bed_occupied_7_day_coverage <dbl>,
## #   total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl>,
## #   total_adult_patients_hospitalized_confirmed_covid_7_day_coverage <dbl>,
## #   total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl>,
## #   total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage <dbl>,
## #   inpatient_beds_7_day_coverage <dbl>, total_icu_beds_7_day_coverage <dbl>,
## #   total_staffed_adult_icu_beds_7_day_coverage <dbl>,
## #   icu_beds_used_7_day_coverage <dbl>,
## #   staffed_adult_icu_bed_occupancy_7_day_coverage <dbl>,
## #   staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage <dbl>,
## #   staffed_icu_adult_patients_confirmed_covid_7_day_coverage <dbl>,
## #   total_patients_hospitalized_confirmed_influenza_7_day_coverage <dbl>,
## #   icu_patients_confirmed_influenza_7_day_coverage <dbl>,
## #   total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage <dbl>,
## #   previous_day_admission_adult_covid_confirmed_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_18-19_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_20-29_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_30-39_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_40-49_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_50-59_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_60-69_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_70-79_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_80+_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_confirmed_unknown_7_day_sum <dbl>,
## #   previous_day_admission_pediatric_covid_confirmed_7_day_sum <dbl>,
## #   previous_day_covid_ED_visits_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_18-19_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_20-29_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_30-39_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_40-49_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_50-59_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_60-69_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_70-79_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_80+_7_day_sum <dbl>,
## #   previous_day_admission_adult_covid_suspected_unknown_7_day_sum <dbl>,
## #   previous_day_admission_pediatric_covid_suspected_7_day_sum <dbl>,
## #   previous_day_total_ED_visits_7_day_sum <dbl>,
## #   previous_day_admission_influenza_confirmed_7_day_sum <dbl>,
## #   geocoded_hospital_address <chr>, hhs_ids <chr>,
## #   previous_day_admission_adult_covid_confirmed_7_day_coverage <dbl>,
## #   previous_day_admission_pediatric_covid_confirmed_7_day_coverage <dbl>,
## #   previous_day_admission_adult_covid_suspected_7_day_coverage <dbl>,
## #   previous_day_admission_pediatric_covid_suspected_7_day_coverage <dbl>,
## #   previous_week_personnel_covid_vaccinated_doses_administered_7_day <dbl>,
## #   total_personnel_covid_vaccinated_doses_none_7_day <dbl>,
## #   total_personnel_covid_vaccinated_doses_one_7_day <dbl>,
## #   total_personnel_covid_vaccinated_doses_all_7_day <dbl>,
## #   previous_week_patients_covid_vaccinated_doses_one_7_day <dbl>,
## #   previous_week_patients_covid_vaccinated_doses_all_7_day <dbl>,
## #   is_corrected <lgl>
# Run for latest data, save as RDS
indivHosp_20211231 <- downloadReadHospitalData(loc="./RInputFiles/Coronavirus/HHS_Hospital_20211231.csv")
## 
## File ./RInputFiles/Coronavirus/HHS_Hospital_20211231.csv already exists
## File will not be downloaded since ovrWrite is not TRUE
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   hospital_pk = col_character(),
##   collection_week = col_date(format = ""),
##   state = col_character(),
##   ccn = col_character(),
##   hospital_name = col_character(),
##   address = col_character(),
##   city = col_character(),
##   zip = col_character(),
##   hospital_subtype = col_character(),
##   fips_code = col_character(),
##   is_metro_micro = col_logical(),
##   geocoded_hospital_address = col_character(),
##   hhs_ids = col_character(),
##   is_corrected = col_logical()
## )
## i Use `spec()` for the full column specifications.
## Rows: 364,751
## Columns: 106
## $ hospital_pk                                                                        <chr> ~
## $ collection_week                                                                    <date> ~
## $ state                                                                              <chr> ~
## $ ccn                                                                                <chr> ~
## $ hospital_name                                                                      <chr> ~
## $ address                                                                            <chr> ~
## $ city                                                                               <chr> ~
## $ zip                                                                                <chr> ~
## $ hospital_subtype                                                                   <chr> ~
## $ fips_code                                                                          <chr> ~
## $ is_metro_micro                                                                     <lgl> ~
## $ total_beds_7_day_avg                                                               <dbl> ~
## $ all_adult_hospital_beds_7_day_avg                                                  <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_avg                                        <dbl> ~
## $ inpatient_beds_used_7_day_avg                                                      <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_avg                                <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg          <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_avg                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg      <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg                    <dbl> ~
## $ inpatient_beds_7_day_avg                                                           <dbl> ~
## $ total_icu_beds_7_day_avg                                                           <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_avg                                             <dbl> ~
## $ icu_beds_used_7_day_avg                                                            <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_avg                                          <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg                 <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_avg                               <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_avg                          <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_avg                                         <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg                <dbl> ~
## $ total_beds_7_day_sum                                                               <dbl> ~
## $ all_adult_hospital_beds_7_day_sum                                                  <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_sum                                        <dbl> ~
## $ inpatient_beds_used_7_day_sum                                                      <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_sum                                <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum          <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_sum                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum      <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum                    <dbl> ~
## $ inpatient_beds_7_day_sum                                                           <dbl> ~
## $ total_icu_beds_7_day_sum                                                           <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_sum                                             <dbl> ~
## $ icu_beds_used_7_day_sum                                                            <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_sum                                          <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum                 <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_sum                               <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_sum                          <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_sum                                         <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum                <dbl> ~
## $ total_beds_7_day_coverage                                                          <dbl> ~
## $ all_adult_hospital_beds_7_day_coverage                                             <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_coverage                                   <dbl> ~
## $ inpatient_beds_used_7_day_coverage                                                 <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_coverage                           <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_coverage                   <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage               <dbl> ~
## $ inpatient_beds_7_day_coverage                                                      <dbl> ~
## $ total_icu_beds_7_day_coverage                                                      <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_coverage                                        <dbl> ~
## $ icu_beds_used_7_day_coverage                                                       <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_coverage                          <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_coverage                     <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_coverage                                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_7_day_sum                             <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_7_day_sum`                       <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_7_day_sum                     <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_7_day_sum                         <dbl> ~
## $ previous_day_covid_ED_visits_7_day_sum                                             <dbl> ~
## $ previous_day_admission_adult_covid_suspected_7_day_sum                             <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_7_day_sum`                       <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_7_day_sum                     <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_7_day_sum                         <dbl> ~
## $ previous_day_total_ED_visits_7_day_sum                                             <dbl> ~
## $ previous_day_admission_influenza_confirmed_7_day_sum                               <dbl> ~
## $ geocoded_hospital_address                                                          <chr> ~
## $ hhs_ids                                                                            <chr> ~
## $ previous_day_admission_adult_covid_confirmed_7_day_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_7_day_coverage                    <dbl> ~
## $ previous_day_admission_adult_covid_suspected_7_day_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_7_day_coverage                    <dbl> ~
## $ previous_week_personnel_covid_vaccinated_doses_administered_7_day                  <dbl> ~
## $ total_personnel_covid_vaccinated_doses_none_7_day                                  <dbl> ~
## $ total_personnel_covid_vaccinated_doses_one_7_day                                   <dbl> ~
## $ total_personnel_covid_vaccinated_doses_all_7_day                                   <dbl> ~
## $ previous_week_patients_covid_vaccinated_doses_one_7_day                            <dbl> ~
## $ previous_week_patients_covid_vaccinated_doses_all_7_day                            <dbl> ~
## $ is_corrected                                                                       <lgl> ~
## 
## Hospital Subtype Counts:
## # A tibble: 4 x 2
##   hospital_subtype               n
##   <chr>                      <int>
## 1 Childrens Hospitals         6850
## 2 Critical Access Hospitals  97451
## 3 Long Term                  25067
## 4 Short Term                235383
## 
## Records other than 50 states and DC
## # A tibble: 5 x 2
##   state     n
##   <chr> <int>
## 1 AS       18
## 2 GU      146
## 3 MP       73
## 4 PR     4029
## 5 VI      146
## 
## Record types for key metrics
## # A tibble: 8 x 6
##   name                             `NA` Positive `Value -999999` Negative  Total
##   <chr>                           <int>    <int>           <int>    <int>  <int>
## 1 all_adult_hospital_beds_7_day_~  6229   357867             655        0 364751
## 2 all_adult_hospital_inpatient_b~  3313   331689           29741        8 364751
## 3 icu_beds_used_7_day_avg          1644   319076           44024        7 364751
## 4 inpatient_beds_7_day_avg         1722   361591            1438        0 364751
## 5 staffed_icu_adult_patients_con~  4243   253046          107462        0 364751
## 6 total_adult_patients_hospitali~  2364   252709          109678        0 364751
## 7 total_beds_7_day_avg             1294   363119             338        0 364751
## 8 total_icu_beds_7_day_avg         2064   344610           18077        0 364751
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

saveToRDS(indivHosp_20211231, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/indivHosp_20211231.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

Updated plots can be produced:

# Example hospital plots for a single state-level segment
indivHosp_20211231 %>% 
    filter(state %in% c(names(cdc_daily_211224$useClusters[cdc_daily_211224$useClusters==7])), 
           collection_week==max(collection_week)
           ) %>% 
    pull(hospital_pk) %>%
    plotHospitalUtilization(df=indivHosp_20211225, keyHosp=., plotTitle="State Segment 7 Hospitals Summed")

The missing data for “adult_beds_occupied” and trend break for “adult_icu_covid” should be explored further. The process is updated to run for each state-level segment:

purrr::walk(.x=sort(unique(cdc_daily_211224$useClusters)), 
            .f=function(segNum) {
                indivHosp_20211231 %>% 
                    filter(state %in% c(names(cdc_daily_211224$useClusters[cdc_daily_211224$useClusters==segNum])), 
                           collection_week==max(collection_week)
                           ) %>% 
                    pull(hospital_pk) %>%
                    plotHospitalUtilization(df=indivHosp_20211225, 
                                            keyHosp=., 
                                            plotTitle=paste0(paste0("State Segment ", segNum, " Hospitals Summed"))
                                            )
                }
)

The latest data are downloaded and processed:

readList <- list("cdcDaily"="./RInputFiles/Coronavirus/CDC_dc_downloaded_220103.csv", 
                 "cdcHosp"="./RInputFiles/Coronavirus/CDC_h_downloaded_220103.csv", 
                 "vax"="./RInputFiles/Coronavirus/vaxData_downloaded_220103.csv"
                 )
compareList <- list("cdcDaily"=readFromRDS("cdc_daily_211224")$dfRaw$cdcDaily, 
                    "cdcHosp"=readFromRDS("cdc_daily_211224")$dfRaw$cdcHosp, 
                    "vax"=readFromRDS("cdc_daily_211224")$dfRaw$vax
                    )

cdc_daily_220103 <- readRunCDCDaily(thruLabel="Jan 02, 2022", 
                                    downloadTo=lapply(readList, FUN=function(x) if(file.exists(x)) NA else x), 
                                    readFrom=readList,
                                    compareFile=compareList, 
                                    writeLog=NULL, 
                                    useClusters=readFromRDS("cdc_daily_210528")$useClusters, 
                                    weightedMeanAggs=c("tcpm7", "tdpm7", "cpm7", "dpm7", "hpm7", 
                                                       "vxcpm7", "vxcgte65pct"
                                                       ),
                                    skipAssessmentPlots=FALSE, 
                                    brewPalette="Paired"
                                    )
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_dc_downloaded_220103.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   submission_date = col_character(),
##   state = col_character(),
##   tot_cases = col_double(),
##   conf_cases = col_double(),
##   prob_cases = col_double(),
##   new_case = col_double(),
##   pnew_case = col_double(),
##   tot_death = col_double(),
##   conf_death = col_double(),
##   prob_death = col_double(),
##   new_death = col_double(),
##   pnew_death = col_double(),
##   created_at = col_character(),
##   consent_cases = col_character(),
##   consent_deaths = col_character()
## )
## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 9
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
##         date       name newValue refValue absDelta   pctDelta
## 1 2021-12-19 new_deaths      194      167       27 0.14958449
## 2 2021-12-18 new_deaths      508      472       36 0.07346939
## 3 2021-12-12 new_deaths      258      242       16 0.06400000
## 4 2021-12-18  new_cases    82555    76510     6045 0.07600666
## 5 2021-12-19  new_cases    99052    94190     4862 0.05032032

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##   state       name newValue refValue absDelta    pctDelta
## 1    NC new_deaths    19295    19233       62 0.003218439
## 2    AL new_deaths    16451    16402       49 0.002982985
## 3    FL new_deaths    62454    62347      107 0.001714730
## 4    NC  new_cases  1610503  1607378     3125 0.001942272
## 5    RI  new_cases   215918   215541      377 0.001747559
## 6    AL  new_cases   863302   862331      971 0.001125384
## 
## 
## 
## Raw file for cdcDaily:
## Rows: 42,600
## Columns: 15
## $ date           <date> 2021-04-01, 2021-05-31, 2020-02-06, 2020-07-30, 2021-0~
## $ state          <chr> "CA", "CA", "NE", "ME", "MS", "NH", "ND", "GU", "NC", "~
## $ tot_cases      <dbl> 3570660, 3685032, 0, 3910, 280182, 2518, 6602, 449, 274~
## $ conf_cases     <dbl> 3570660, 3685032, NA, 3497, 176228, NA, 6602, NA, 26208~
## $ prob_cases     <dbl> 0, 0, NA, 413, 103954, NA, 0, NA, 12226, NA, 219, NA, 1~
## $ new_cases      <dbl> 2234, 644, 0, 22, 1059, 89, 133, 15, 2333, 798, 386, 0,~
## $ pnew_case      <dbl> 0, 0, NA, 2, 559, 0, 0, 0, 244, 0, 5, NA, 0, 94, 45, 0,~
## $ tot_deaths     <dbl> 58090, 62011, 0, 123, 6730, 86, 103, 5, 4731, 4169, 681~
## $ conf_death     <dbl> 58090, 62011, NA, 122, 4739, NA, NA, NA, 4623, 4012, 63~
## $ prob_death     <dbl> 0, 0, NA, 1, 1991, NA, NA, NA, 108, 157, 42, NA, 1332, ~
## $ new_deaths     <dbl> 154, 5, 0, 2, 13, 2, 0, 0, 34, 7, 16, 0, 0, 8, 0, 33, 0~
## $ pnew_death     <dbl> 0, 0, NA, 0, 7, 0, 0, 0, 2, 0, 2, NA, 0, 0, 0, 0, NA, 8~
## $ created_at     <chr> "04/03/2021 12:00:00 AM", "06/02/2021 12:00:00 AM", "03~
## $ consent_cases  <chr> "Agree", "Agree", "Agree", "Agree", "Agree", "Not agree~
## $ consent_deaths <chr> "Agree", "Agree", "Agree", "Agree", "Agree", "Not agree~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/CDC_h_downloaded_220103.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   state = col_character(),
##   date = col_date(format = ""),
##   geocoded_state = col_logical()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 10
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 5 and at least 5%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)

## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
##    state     name newValue refValue absDelta    pctDelta
## 1     NC      inp  1001010   997299     3711 0.003714140
## 2     NH hosp_ped      579      537       42 0.075268817
## 3     KS hosp_ped     2894     3085      191 0.063890283
## 4     MD hosp_ped     9405     9733      328 0.034277354
## 5     NJ hosp_ped    12257    12016      241 0.019857455
## 6     WV hosp_ped     3592     3663       71 0.019572708
## 7     VA hosp_ped    10634    10456      178 0.016880038
## 8     DE hosp_ped     2949     2909       40 0.013656538
## 9     NV hosp_ped     3170     3133       37 0.011740441
## 10    AZ hosp_ped    18483    18664      181 0.009745067
## 11    AL hosp_ped    13741    13622      119 0.008697877
## 12    KY hosp_ped    12337    12429       92 0.007429540
## 13    MA hosp_ped     6703     6658       45 0.006736023
## 14    SC hosp_ped     5397     5432       35 0.006464124
## 15    UT hosp_ped     5232     5265       33 0.006287511
## 16    AR hosp_ped     8608     8555       53 0.006176076
## 17    TN hosp_ped    13309    13384       75 0.005619451
## 18    CT hosp_ped     3233     3251       18 0.005552128
## 19    VT hosp_ped      210      211        1 0.004750594
## 20    SD hosp_ped     3155     3166       11 0.003480462
## 21    NC hosp_ped    17837    17778       59 0.003313211
## 22    CO hosp_ped    14704    14749       45 0.003055716
## 23    OK hosp_ped    17313    17271       42 0.002428869
## 24    NM hosp_ped     4955     4943       12 0.002424732
## 25    RI hosp_ped     2060     2065        5 0.002424242
## 26    NY hosp_ped    44591    44484      107 0.002402470
## 27    IL hosp_ped    28075    28009       66 0.002353612
## 28    ME hosp_ped      885      887        2 0.002257336
## 29    MS hosp_ped     7448     7463       15 0.002011937
## 30    PR hosp_ped    14354    14382       28 0.001948775
## 31    PA hosp_ped    34007    33952       55 0.001618623
## 32    HI hosp_ped     1483     1481        2 0.001349528
## 33    GA hosp_ped    34629    34583       46 0.001329249
## 34    ND hosp_ped     2320     2323        3 0.001292268
## 35    CA hosp_ped    45739    45684       55 0.001203198
## 36    WI hosp_ped     6916     6909        7 0.001012658
## 
## 
## 
## Raw file for cdcHosp:
## Rows: 36,028
## Columns: 117
## $ state                                                                        <chr> ~
## $ date                                                                         <date> ~
## $ critical_staffing_shortage_today_yes                                         <dbl> ~
## $ critical_staffing_shortage_today_no                                          <dbl> ~
## $ critical_staffing_shortage_today_not_reported                                <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_yes                       <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_no                        <dbl> ~
## $ critical_staffing_shortage_anticipated_within_week_not_reported              <dbl> ~
## $ hospital_onset_covid                                                         <dbl> ~
## $ hospital_onset_covid_coverage                                                <dbl> ~
## $ inpatient_beds                                                               <dbl> ~
## $ inpatient_beds_coverage                                                      <dbl> ~
## $ inpatient_beds_used                                                          <dbl> ~
## $ inpatient_beds_used_coverage                                                 <dbl> ~
## $ inp                                                                          <dbl> ~
## $ inpatient_beds_used_covid_coverage                                           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed                                 <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_coverage                        <dbl> ~
## $ previous_day_admission_adult_covid_suspected                                 <dbl> ~
## $ previous_day_admission_adult_covid_suspected_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed                             <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_coverage                    <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected                             <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_coverage                    <dbl> ~
## $ staffed_adult_icu_bed_occupancy                                              <dbl> ~
## $ staffed_adult_icu_bed_occupancy_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid                                   <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_coverage                          <dbl> ~
## $ hosp_adult                                                                   <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid                            <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_coverage                   <dbl> ~
## $ hosp_ped                                                                     <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_coverage               <dbl> ~
## $ total_staffed_adult_icu_beds                                                 <dbl> ~
## $ total_staffed_adult_icu_beds_coverage                                        <dbl> ~
## $ inpatient_beds_utilization                                                   <dbl> ~
## $ inpatient_beds_utilization_coverage                                          <dbl> ~
## $ inpatient_beds_utilization_numerator                                         <dbl> ~
## $ inpatient_beds_utilization_denominator                                       <dbl> ~
## $ percent_of_inpatients_with_covid                                             <dbl> ~
## $ percent_of_inpatients_with_covid_coverage                                    <dbl> ~
## $ percent_of_inpatients_with_covid_numerator                                   <dbl> ~
## $ percent_of_inpatients_with_covid_denominator                                 <dbl> ~
## $ inpatient_bed_covid_utilization                                              <dbl> ~
## $ inpatient_bed_covid_utilization_coverage                                     <dbl> ~
## $ inpatient_bed_covid_utilization_numerator                                    <dbl> ~
## $ inpatient_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_covid_utilization                                              <dbl> ~
## $ adult_icu_bed_covid_utilization_coverage                                     <dbl> ~
## $ adult_icu_bed_covid_utilization_numerator                                    <dbl> ~
## $ adult_icu_bed_covid_utilization_denominator                                  <dbl> ~
## $ adult_icu_bed_utilization                                                    <dbl> ~
## $ adult_icu_bed_utilization_coverage                                           <dbl> ~
## $ adult_icu_bed_utilization_numerator                                          <dbl> ~
## $ adult_icu_bed_utilization_denominator                                        <dbl> ~
## $ geocoded_state                                                               <lgl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_coverage                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79`                         <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_coverage`                <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+`                           <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_coverage`                  <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown                         <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_coverage                <dbl> ~
## $ deaths_covid                                                                 <dbl> ~
## $ deaths_covid_coverage                                                        <dbl> ~
## $ on_hand_supply_therapeutic_a_casirivimab_imdevimab_courses                   <dbl> ~
## $ on_hand_supply_therapeutic_b_bamlanivimab_courses                            <dbl> ~
## $ on_hand_supply_therapeutic_c_bamlanivimab_etesevimab_courses                 <dbl> ~
## $ previous_week_therapeutic_a_casirivimab_imdevimab_courses_used               <dbl> ~
## $ previous_week_therapeutic_b_bamlanivimab_courses_used                        <dbl> ~
## $ previous_week_therapeutic_c_bamlanivimab_etesevimab_courses_used             <dbl> ~
## $ icu_patients_confirmed_influenza                                             <dbl> ~
## $ icu_patients_confirmed_influenza_coverage                                    <dbl> ~
## $ previous_day_admission_influenza_confirmed                                   <dbl> ~
## $ previous_day_admission_influenza_confirmed_coverage                          <dbl> ~
## $ previous_day_deaths_covid_and_influenza                                      <dbl> ~
## $ previous_day_deaths_covid_and_influenza_coverage                             <dbl> ~
## $ previous_day_deaths_influenza                                                <dbl> ~
## $ previous_day_deaths_influenza_coverage                                       <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza                              <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_coverage           <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_coverage                     <dbl> ~
## 
## No file has been downloaded, will use existing file: ./RInputFiles/Coronavirus/vaxData_downloaded_220103.csv
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   Date = col_character(),
##   Location = col_character()
## )
## i Use `spec()` for the full column specifications.

## 
## *** File has been checked for uniqueness by: state date

## 
## 
## Checking for similarity of: column names
## In reference but not in current: 
## In current but not in reference: 
## 
## Checking for similarity of: date
## In reference but not in current: 0
## In current but not in reference: 7
## 
## Checking for similarity of: state
## In reference but not in current: 
## In current but not in reference:

## 
## 
## ***Differences of at least 1 and at least 1%
## 
## [1] date     name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## ***Differences of at least 0 and at least 0.1%
## 
## [1] state    name     newValue refValue absDelta pctDelta
## <0 rows> (or 0-length row.names)
## 
## 
## 
## Raw file for vax:
## Rows: 24,728
## Columns: 80
## $ date                                   <date> 2021-12-30, 2021-12-30, 2021-1~
## $ MMWR_week                              <dbl> 52, 52, 52, 52, 52, 52, 52, 52,~
## $ state                                  <chr> "WV", "NY", "ME", "KS", "WI", "~
## $ Distributed                            <dbl> 3344485, 39052505, 2908420, 517~
## $ Distributed_Janssen                    <dbl> 156400, 1789500, 150600, 249000~
## $ Distributed_Moderna                    <dbl> 1165240, 13435720, 1120600, 195~
## $ Distributed_Pfizer                     <dbl> 2022845, 23827285, 1637220, 297~
## $ Distributed_Unk_Manuf                  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0~
## $ Dist_Per_100K                          <dbl> 186619, 200747, 216366, 177730,~
## $ Distributed_Per_100k_12Plus            <dbl> 214688, 232827, 245450, 211194,~
## $ Distributed_Per_100k_18Plus            <dbl> 233459, 253172, 265519, 233966,~
## $ Distributed_Per_100k_65Plus            <dbl> 911277, 1184790, 1019550, 10889~
## $ vxa                                    <dbl> 2490508, 34256514, 2508118, 407~
## $ Administered_12Plus                    <dbl> 2457972, 33507499, 2440464, 398~
## $ Administered_18Plus                    <dbl> 2346955, 31564214, 2314179, 373~
## $ Administered_65Plus                    <dbl> 828621, 7938556, 774178, 114864~
## $ Administered_Janssen                   <dbl> 63838, 1344059, 138615, 128180,~
## $ Administered_Moderna                   <dbl> 1080327, 12566165, 1026213, 157~
## $ Administered_Pfizer                    <dbl> 1344726, 20330689, 1340722, 236~
## $ Administered_Unk_Manuf                 <dbl> 1617, 15601, 2568, 3354, 1790, ~
## $ Admin_Per_100k                         <dbl> 138968, 176094, 186586, 139833,~
## $ Admin_Per_100k_12Plus                  <dbl> 157781, 199768, 205957, 162434,~
## $ Admin_Per_100k_18Plus                  <dbl> 163827, 204627, 211269, 168573,~
## $ Admin_Per_100k_65Plus                  <dbl> 225776, 240844, 271389, 241573,~
## $ Recip_Administered                     <dbl> 2481826, 34257536, 2519706, 417~
## $ Administered_Dose1_Recip               <dbl> 1109524, 16343955, 1154119, 201~
## $ Administered_Dose1_Pop_Pct             <dbl> 61.9, 84.0, 85.9, 69.3, 68.2, 6~
## $ Administered_Dose1_Recip_12Plus        <dbl> 1089308, 15876430, 1116022, 196~
## $ Administered_Dose1_Recip_12PlusPop_Pct <dbl> 69.9, 94.7, 94.2, 80.0, 77.0, 7~
## $ Administered_Dose1_Recip_18Plus        <dbl> 1031604, 14856332, 1052121, 182~
## $ Administered_Dose1_Recip_18PlusPop_Pct <dbl> 72.0, 95.0, 95.0, 82.6, 79.1, 7~
## $ Administered_Dose1_Recip_65Plus        <dbl> 333931, 3374517, 319008, 514743~
## $ Administered_Dose1_Recip_65PlusPop_Pct <dbl> 91.0, 95.0, 95.0, 95.0, 95.0, 9~
## $ vxc                                    <dbl> 986688, 13961789, 1019209, 1661~
## $ vxcpoppct                              <dbl> 55.1, 71.8, 75.8, 57.0, 62.0, 5~
## $ Series_Complete_12Plus                 <dbl> 974298, 13678603, 989971, 16266~
## $ Series_Complete_12PlusPop_Pct          <dbl> 62.5, 81.6, 83.5, 66.3, 70.4, 6~
## $ vxcgte18                               <dbl> 923854, 12786149, 931969, 15142~
## $ vxcgte18pct                            <dbl> 64.5, 82.9, 85.1, 68.4, 72.5, 6~
## $ vxcgte65                               <dbl> 304047, 2925706, 278312, 419367~
## $ vxcgte65pct                            <dbl> 82.8, 88.8, 95.0, 88.2, 93.5, 8~
## $ Series_Complete_Janssen                <dbl> 58481, 1203587, 128481, 117897,~
## $ Series_Complete_Moderna                <dbl> 409874, 4800641, 371443, 606491~
## $ Series_Complete_Pfizer                 <dbl> 517891, 7953437, 518728, 936172~
## $ Series_Complete_Unk_Manuf              <dbl> 442, 4124, 557, 610, 592, 4, 21~
## $ Series_Complete_Janssen_12Plus         <dbl> 58464, 1203406, 128459, 117877,~
## $ Series_Complete_Moderna_12Plus         <dbl> 409783, 4800070, 371424, 606475~
## $ Series_Complete_Pfizer_12Plus          <dbl> 505611, 7671070, 489532, 901724~
## $ Series_Complete_Unk_Manuf_12Plus       <dbl> 440, 4057, 556, 606, 591, 4, 21~
## $ Series_Complete_Janssen_18Plus         <dbl> 58409, 1202630, 128403, 117769,~
## $ Series_Complete_Moderna_18Plus         <dbl> 409423, 4798084, 371366, 606123~
## $ Series_Complete_Pfizer_18Plus          <dbl> 455611, 6781663, 431691, 789846~
## $ Series_Complete_Unk_Manuf_18Plus       <dbl> 411, 3772, 509, 531, 565, 4, 20~
## $ Series_Complete_Janssen_65Plus         <dbl> 9431, 183872, 24414, 18152, 300~
## $ Series_Complete_Moderna_65Plus         <dbl> 155599, 1381920, 126724, 199682~
## $ Series_Complete_Pfizer_65Plus          <dbl> 138826, 1358310, 126945, 201282~
## $ Series_Complete_Unk_Manuf_65Plus       <dbl> 191, 1604, 229, 251, 253, 1, 75~
## $ Additional_Doses                       <dbl> 369484, 4543102, 448113, 554996~
## $ Additional_Doses_Vax_Pct               <dbl> 37.4, 32.5, 44.0, 33.4, 44.4, 3~
## $ Additional_Doses_18Plus                <dbl> 367744, 4510445, 444887, 550751~
## $ Additional_Doses_18Plus_Vax_Pct        <dbl> 39.8, 35.3, 47.7, 36.4, 48.2, 3~
## $ Additional_Doses_50Plus                <dbl> 282480, 3008478, 325651, 390779~
## $ Additional_Doses_50Plus_Vax_Pct        <dbl> 50.3, 47.6, 59.9, 48.1, 60.9, 5~
## $ Additional_Doses_65Plus                <dbl> 180399, 1695530, 194176, 243080~
## $ Additional_Doses_65Plus_Vax_Pct        <dbl> 59.3, 58.0, 69.8, 58.0, 72.3, 6~
## $ Additional_Doses_Moderna               <dbl> 176516, 2019212, 212290, 248509~
## $ Additional_Doses_Pfizer                <dbl> 189144, 2444709, 226615, 298262~
## $ Additional_Doses_Janssen               <dbl> 3769, 78940, 8913, 8101, 22104,~
## $ Additional_Doses_Unk_Manuf             <dbl> 55, 241, 295, 124, 55, 3, 211, ~
## $ Administered_Dose1_Recip_5Plus         <dbl> 1109130, 16342423, 1154000, 201~
## $ Administered_Dose1_Recip_5PlusPop_Pct  <dbl> 65.3, 89.2, 90.1, 74.0, 72.3, 6~
## $ Series_Complete_5Plus                  <dbl> 986456, 13961401, 1019177, 1661~
## $ Series_Complete_5PlusPop_Pct           <dbl> 58.1, 76.2, 79.6, 60.9, 65.7, 5~
## $ Administered_5Plus                     <dbl> 2489811, 34254491, 2507987, 407~
## $ Admin_Per_100k_5Plus                   <dbl> 146535, 186912, 195833, 149328,~
## $ Distributed_Per_100k_5Plus             <dbl> 196836, 213092, 227101, 189804,~
## $ Series_Complete_Moderna_5Plus          <dbl> 409797, 4800525, 371436, 606483~
## $ Series_Complete_Pfizer_5Plus           <dbl> 517751, 7953284, 518722, 936166~
## $ Series_Complete_Janssen_5Plus          <dbl> 58466, 1203483, 128462, 117892,~
## $ Series_Complete_Unk_Manuf_5Plus        <dbl> 442, 4109, 557, 610, 592, 4, 21~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 6
##   isType tot_cases tot_deaths new_cases   new_deaths         n
##   <chr>      <dbl>      <dbl>     <dbl>        <dbl>     <dbl>
## 1 before  1.50e+10    2.74e+8   5.44e+7 803968       41890    
## 2 after   1.49e+10    2.73e+8   5.41e+7 800305       36210    
## 3 pctchg  4.39e- 3    4.26e-3   5.60e-3      0.00456     0.136
## 
## 
## Processed for cdcDaily:
## Rows: 36,210
## Columns: 6
## $ date       <date> 2021-04-01, 2021-05-31, 2020-02-06, 2020-07-30, 2021-02-02~
## $ state      <chr> "CA", "CA", "NE", "ME", "MS", "NH", "ND", "NC", "MD", "AL",~
## $ tot_cases  <dbl> 3570660, 3685032, 0, 3910, 280182, 2518, 6602, 274314, 1351~
## $ tot_deaths <dbl> 58090, 62011, 0, 123, 6730, 86, 103, 4731, 4169, 681, 0, 73~
## $ new_cases  <dbl> 2234, 644, 0, 22, 1059, 89, 133, 2333, 798, 386, 0, 0, 1502~
## $ new_deaths <dbl> 154, 5, 0, 2, 13, 2, 0, 34, 7, 16, 0, 0, 8, 0, 33, 0, 32, 6~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 5
##   isType     inp hosp_adult    hosp_ped          n
##   <chr>    <dbl>      <dbl>       <dbl>      <dbl>
## 1 before 3.90e+7    3.29e+7 749511      36028     
## 2 after  3.88e+7    3.27e+7 734450      34584     
## 3 pctchg 4.85e-3    4.65e-3      0.0201     0.0401
## 
## 
## Processed for cdcHosp:
## Rows: 34,584
## Columns: 5
## $ date       <date> 2020-10-18, 2020-10-15, 2020-10-14, 2020-10-13, 2020-10-13~
## $ state      <chr> "VT", "AK", "RI", "AR", "NH", "NC", "HI", "ND", "ID", "NH",~
## $ inp        <dbl> 2, 59, 128, 732, 34, 1329, 110, 255, 191, 46, 420, 91, 42, ~
## $ hosp_adult <dbl> 2, 58, 128, 710, 34, 1311, 108, 246, 189, 46, 417, 90, 42, ~
## $ hosp_ped   <dbl> 0, 1, 0, 11, 0, 17, 2, 9, 2, 0, 3, 1, 0, 6, 2, 1, 4, 1, 15,~
## 
## Column sums before and after applying filtering rules:
## # A tibble: 3 x 9
##   isType      vxa      vxc  vxcpoppct vxcgte65  vxcgte65pct vxcgte18 vxcgte18pct
##   <chr>     <dbl>    <dbl>      <dbl>    <dbl>        <dbl>    <dbl>       <dbl>
## 1 before 2.10e+11 9.12e+10 810774.    2.53e+10 1294323      8.66e+10  978759.   
## 2 after  1.01e+11 4.41e+10 681735.    1.22e+10 1166666.     4.18e+10  832309.   
## 3 pctchg 5.21e- 1 5.17e- 1      0.159 5.16e- 1       0.0986 5.17e- 1       0.150
## # ... with 1 more variable: n <dbl>
## 
## 
## Processed for vax:
## Rows: 19,482
## Columns: 9
## $ date        <date> 2021-12-30, 2021-12-30, 2021-12-30, 2021-12-30, 2021-12-3~
## $ state       <chr> "WV", "NY", "ME", "KS", "WI", "ND", "CO", "DC", "MO", "OR"~
## $ vxa         <dbl> 2490508, 34256514, 2508118, 4073766, 9114543, 1013290, 951~
## $ vxc         <dbl> 986688, 13961789, 1019209, 1661170, 3607515, 400490, 38135~
## $ vxcpoppct   <dbl> 55.1, 71.8, 75.8, 57.0, 62.0, 52.6, 66.2, 67.6, 53.0, 66.5~
## $ vxcgte65    <dbl> 304047, 2925706, 278312, 419367, 950813, 101294, 751171, 7~
## $ vxcgte65pct <dbl> 82.8, 88.8, 95.0, 88.2, 93.5, 84.5, 89.2, 88.8, 82.4, 89.2~
## $ vxcgte18    <dbl> 923854, 12786149, 931969, 1514269, 3301306, 370742, 344120~
## $ vxcgte18pct <dbl> 64.5, 82.9, 85.1, 68.4, 72.5, 63.7, 76.5, 77.3, 63.0, 76.3~
## 
## Integrated per capita data file:
## Rows: 36,474
## Columns: 34
## $ date        <date> 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-01, 2020-01-0~
## $ state       <chr> "AL", "HI", "IN", "LA", "MN", "MT", "NC", "TX", "AL", "HI"~
## $ tot_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tot_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_cases   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ new_deaths  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ inp         <dbl> NA, 0, 0, NA, 0, 0, 0, 0, NA, 0, 0, NA, 0, 0, 0, 1877, 0, ~
## $ hosp_adult  <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hosp_ped    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxa         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxc         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpoppct   <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte65pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18    <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcgte18pct <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm         <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm         <dbl> NA, 0.0000, 0.0000, NA, 0.0000, 0.0000, 0.0000, 0.0000, NA~
## $ ahpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tcpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ tdpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ cpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ dpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ hpm7        <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ ahpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ phpm7       <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxapm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## $ vxcpm7      <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA~
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum unknown in CRS definition

saveToRDS(cdc_daily_220103, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/cdc_daily_220103.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The latest hospital data are downloaded:

# Run for latest data, save as RDS
indivHosp_20220109 <- downloadReadHospitalData(loc="./RInputFiles/Coronavirus/HHS_Hospital_20220109.csv")
## 
## File ./RInputFiles/Coronavirus/HHS_Hospital_20220109.csv already exists
## File will not be downloaded since ovrWrite is not TRUE
## 
## -- Column specification --------------------------------------------------------
## cols(
##   .default = col_double(),
##   hospital_pk = col_character(),
##   collection_week = col_date(format = ""),
##   state = col_character(),
##   ccn = col_character(),
##   hospital_name = col_character(),
##   address = col_character(),
##   city = col_character(),
##   zip = col_character(),
##   hospital_subtype = col_character(),
##   fips_code = col_character(),
##   is_metro_micro = col_logical(),
##   geocoded_hospital_address = col_character(),
##   hhs_ids = col_character(),
##   is_corrected = col_logical()
## )
## i Use `spec()` for the full column specifications.
## Rows: 369,758
## Columns: 106
## $ hospital_pk                                                                        <chr> ~
## $ collection_week                                                                    <date> ~
## $ state                                                                              <chr> ~
## $ ccn                                                                                <chr> ~
## $ hospital_name                                                                      <chr> ~
## $ address                                                                            <chr> ~
## $ city                                                                               <chr> ~
## $ zip                                                                                <chr> ~
## $ hospital_subtype                                                                   <chr> ~
## $ fips_code                                                                          <chr> ~
## $ is_metro_micro                                                                     <lgl> ~
## $ total_beds_7_day_avg                                                               <dbl> ~
## $ all_adult_hospital_beds_7_day_avg                                                  <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_avg                                        <dbl> ~
## $ inpatient_beds_used_7_day_avg                                                      <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_avg                                <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg          <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_avg                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_avg      <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_avg                    <dbl> ~
## $ inpatient_beds_7_day_avg                                                           <dbl> ~
## $ total_icu_beds_7_day_avg                                                           <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_avg                                             <dbl> ~
## $ icu_beds_used_7_day_avg                                                            <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_avg                                          <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_avg                 <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_avg                               <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_avg                          <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_avg                                         <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_avg                <dbl> ~
## $ total_beds_7_day_sum                                                               <dbl> ~
## $ all_adult_hospital_beds_7_day_sum                                                  <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_sum                                        <dbl> ~
## $ inpatient_beds_used_7_day_sum                                                      <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_sum                                <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum          <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_sum                        <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_sum      <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_sum                    <dbl> ~
## $ inpatient_beds_7_day_sum                                                           <dbl> ~
## $ total_icu_beds_7_day_sum                                                           <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_sum                                             <dbl> ~
## $ icu_beds_used_7_day_sum                                                            <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_sum                                          <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_sum                 <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_sum                               <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_sum                          <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_sum                                         <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_sum                <dbl> ~
## $ total_beds_7_day_coverage                                                          <dbl> ~
## $ all_adult_hospital_beds_7_day_coverage                                             <dbl> ~
## $ all_adult_hospital_inpatient_beds_7_day_coverage                                   <dbl> ~
## $ inpatient_beds_used_7_day_coverage                                                 <dbl> ~
## $ all_adult_hospital_inpatient_bed_occupied_7_day_coverage                           <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage     <dbl> ~
## $ total_adult_patients_hospitalized_confirmed_covid_7_day_coverage                   <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_and_suspected_covid_7_day_coverage <dbl> ~
## $ total_pediatric_patients_hospitalized_confirmed_covid_7_day_coverage               <dbl> ~
## $ inpatient_beds_7_day_coverage                                                      <dbl> ~
## $ total_icu_beds_7_day_coverage                                                      <dbl> ~
## $ total_staffed_adult_icu_beds_7_day_coverage                                        <dbl> ~
## $ icu_beds_used_7_day_coverage                                                       <dbl> ~
## $ staffed_adult_icu_bed_occupancy_7_day_coverage                                     <dbl> ~
## $ staffed_icu_adult_patients_confirmed_and_suspected_covid_7_day_coverage            <dbl> ~
## $ staffed_icu_adult_patients_confirmed_covid_7_day_coverage                          <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_7_day_coverage                     <dbl> ~
## $ icu_patients_confirmed_influenza_7_day_coverage                                    <dbl> ~
## $ total_patients_hospitalized_confirmed_influenza_and_covid_7_day_coverage           <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_7_day_sum                             <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_18-19_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_20-29_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_30-39_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_40-49_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_50-59_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_60-69_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_70-79_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_confirmed_80+_7_day_sum`                       <dbl> ~
## $ previous_day_admission_adult_covid_confirmed_unknown_7_day_sum                     <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_7_day_sum                         <dbl> ~
## $ previous_day_covid_ED_visits_7_day_sum                                             <dbl> ~
## $ previous_day_admission_adult_covid_suspected_7_day_sum                             <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_18-19_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_20-29_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_30-39_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_40-49_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_50-59_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_60-69_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_70-79_7_day_sum`                     <dbl> ~
## $ `previous_day_admission_adult_covid_suspected_80+_7_day_sum`                       <dbl> ~
## $ previous_day_admission_adult_covid_suspected_unknown_7_day_sum                     <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_7_day_sum                         <dbl> ~
## $ previous_day_total_ED_visits_7_day_sum                                             <dbl> ~
## $ previous_day_admission_influenza_confirmed_7_day_sum                               <dbl> ~
## $ geocoded_hospital_address                                                          <chr> ~
## $ hhs_ids                                                                            <chr> ~
## $ previous_day_admission_adult_covid_confirmed_7_day_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_confirmed_7_day_coverage                    <dbl> ~
## $ previous_day_admission_adult_covid_suspected_7_day_coverage                        <dbl> ~
## $ previous_day_admission_pediatric_covid_suspected_7_day_coverage                    <dbl> ~
## $ previous_week_personnel_covid_vaccinated_doses_administered_7_day                  <dbl> ~
## $ total_personnel_covid_vaccinated_doses_none_7_day                                  <dbl> ~
## $ total_personnel_covid_vaccinated_doses_one_7_day                                   <dbl> ~
## $ total_personnel_covid_vaccinated_doses_all_7_day                                   <dbl> ~
## $ previous_week_patients_covid_vaccinated_doses_one_7_day                            <dbl> ~
## $ previous_week_patients_covid_vaccinated_doses_all_7_day                            <dbl> ~
## $ is_corrected                                                                       <lgl> ~
## 
## Hospital Subtype Counts:
## # A tibble: 4 x 2
##   hospital_subtype               n
##   <chr>                      <int>
## 1 Childrens Hospitals         6943
## 2 Critical Access Hospitals  98792
## 3 Long Term                  25409
## 4 Short Term                238614
## 
## Records other than 50 states and DC
## # A tibble: 5 x 2
##   state     n
##   <chr> <int>
## 1 AS       19
## 2 GU      148
## 3 MP       74
## 4 PR     4082
## 5 VI      148
## 
## Record types for key metrics
## # A tibble: 8 x 6
##   name                             `NA` Positive `Value -999999` Negative  Total
##   <chr>                           <int>    <int>           <int>    <int>  <int>
## 1 all_adult_hospital_beds_7_day_~  6229   362863             666        0 369758
## 2 all_adult_hospital_inpatient_b~  3313   336307           30130        8 369758
## 3 icu_beds_used_7_day_avg          1644   323534           44573        7 369758
## 4 inpatient_beds_7_day_avg         1722   366579            1457        0 369758
## 5 staffed_icu_adult_patients_con~  4243   256690          108825        0 369758
## 6 total_adult_patients_hospitali~  2364   256272          111122        0 369758
## 7 total_beds_7_day_avg             1294   368119             345        0 369758
## 8 total_icu_beds_7_day_avg         2064   349349           18345        0 369758
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

saveToRDS(indivHosp_20220109, ovrWriteError=FALSE)
## 
## File already exists: ./RInputFiles/Coronavirus/indivHosp_20220109.RDS 
## 
## Not replacing the existing file since ovrWrite=FALSE
## NULL

The process is updated to run for each state-level segment:

purrr::walk(.x=sort(unique(cdc_daily_220103$useClusters)), 
            .f=function(segNum) {
                indivHosp_20220109 %>% 
                    filter(state %in% c(names(cdc_daily_220103$useClusters[cdc_daily_220103$useClusters==segNum])), 
                           collection_week==max(collection_week)
                           ) %>% 
                    pull(hospital_pk) %>%
                    plotHospitalUtilization(df=indivHosp_20220109, 
                                            keyHosp=., 
                                            plotTitle=paste0(paste0("State Segment ", segNum, " Hospitals Summed"))
                                            )
                }
)

A summary is also created for all US hospitals:

indivHosp_20220109 %>% 
    filter(state %in% c(state.abb, "DC"), 
           collection_week==max(collection_week)
    ) %>% 
    pull(hospital_pk) %>%
    plotHospitalUtilization(df=indivHosp_20220109, keyHosp=., plotTitle="US Hospitals Summed")

Maps are created for the ICU utilization by state:

stateHosp_20220109 <- indivHosp_20220109 %>%
    filter(state %in% c(state.abb, "DC")) %>%
    colSelector(c("state", "collection_week", names(hhsMapper))) %>%
    colRenamer(hhsMapper) %>%
    mutate(across(where(is.numeric), .fns=function(x) ifelse(is.na(x), NA, ifelse(x==-999999, NA, x)))) %>%
    group_by(state, collection_week) %>%
    summarize(across(where(is.numeric), .fns=sum, na.rm=TRUE), n=n(),.groups="drop")

library(geofacet)
## Warning: package 'geofacet' was built under R version 4.1.2
stateHosp_20220109 %>%
    mutate(pctICU=icu_beds_occupied/icu_beds, pctCovidICU=adult_icu_covid/icu_beds) %>%
    ggplot(aes(x=collection_week)) + 
    geom_line(aes(y=pctICU, color="Total")) + 
    geom_line(aes(y=pctCovidICU, color="Covid")) +
    scale_color_manual("% ICU\nUsed", values=c("Total"="black", "Covid"="red")) + 
    labs(x=NULL, 
         y=NULL, 
         title="Average % ICU Capacity Filled by Week", 
         subtitle="August 2020 to December 2021"
         ) + 
    theme(axis.text.x = element_blank()) +
    geom_hline(yintercept=1, lty=2) +
    facet_geo(~state)

The process is converted to functional form:

createGeoMap <- function(df, 
                         yVars,
                         xVar="collection_week",
                         facetVar="state",
                         lstFilter=list(), 
                         lstExclude=list(), 
                         vecSelect=NULL, 
                         vecRename=c(), 
                         selfList=list(), 
                         fullList=list(), 
                         plotTitle=NULL, 
                         plotSubtitle=NULL,
                         plotYLab=NULL, 
                         plotScaleLabel=NULL, 
                         createPlot=TRUE,
                         facetScaleType="fixed",
                         hLine=1,
                         noX=TRUE, 
                         noY=FALSE,
                         returnData=FALSE
                         ) {
    
    # FUNCTION ARGUMENTS:
    # df: the data frame containing the relevant data
    # yVars: list of the y-variables, of form list("yVar1"=c("label"="y1Label", "color"="y1Color"), "yVar2"=...)
    # xVar: the x-variable to use for the plots
    # facetVar: the variable for faceting the data
    # lstFilter: a list for filtering records, of form list("field"=c("allowed values"))
    # lstExclude: a list for filtering records, of form list("field"=c("disallowed values"))
    # vecSelect: vector for variables to keep c('keep1', "keep2", ...), NULL means keep all
    # vecRename: vector for renaming c('existing name'='new name'), can be any length from 0 to ncol(df)
    # selfList: list for functions to apply to self, list('variable'=fn) will apply variable=fn(variable)
    #           processed in order, so more than one function can be applied to self
    # fullList: list for general functions to be applied, list('new variable'=expression(code))
    #           will create 'new variable' as eval(expression(code))
    #           for now, requires passing an expression
    # plotTitle: title for plot
    # plotSubtitle: subtitle for plot
    # plotYLab: y-label for plot
    # plotScaleLabel: scale label for plot
    # createPlot: boolean, should the plot be created and printed?
    # facetScaleType: argument passed to facet_wrap - "fixed", "free", "free_y", "free_x"
    # hLine: height for a dashed horizontal line (NULL means none)
    # noX: boolean, should the x-axis be removed?
    # noY: boolean, should the y-axis be removed?
    # returnData: boolean, should the data frame dfMod be returned?
    
    # Create the modified data
    dfMod <- df %>%
        rowFilter(lstFilter=lstFilter, lstExclude=lstExclude) %>%
        colSelector(vecSelect=vecSelect) %>%
        colRenamer(vecRename=vecRename) %>%
        colMutater(selfList=selfList, fullList=fullList)
    
    if(isTRUE(createPlot)) {
        
        # Create the plot data frame
        dfPlot <- dfMod %>%
            colSelector(c(facetVar, xVar, names(yVars))) %>%
            pivot_longer(names(yVars))
        
        # Create the color mapper
        vecColor <- sapply(yVars, FUN=function(x) x[["color"]]) %>%
            purrr::set_names(names(yVars))
    
        # Create the plot
        p1 <- dfPlot %>%
            colRenamer(c("facetVar") %>% purrr::set_names(facetVar)) %>%
            ggplot(aes_string(x=xVar, y="value", group="name", color="name")) + 
            geom_line() +
            scale_color_manual(plotScaleLabel, 
                               values=vecColor, 
                               labels=sapply(yVars, FUN=function(x) x[["label"]])
                               ) + 
            labs(x=NULL, y=plotYLab, title=plotTitle, subtitle=plotSubtitle) + 
            lims(y=c(0, NA)) +
            facet_geo(~facetVar, scales=facetScaleType)
        if(!is.null(hLine)) p1 <- p1 + geom_hline(yintercept=hLine, lty=2)
        if(isTRUE(noX)) p1 <- p1 + theme(axis.text.x = element_blank())
        if(isTRUE(noY)) p1 <- p1 + theme(axis.text.y = element_blank())
    
        # Print the plot
        print(p1)
        
    }

    # Return the data if requested(?)
    if(isTRUE(returnData)) return(dfMod)
    
}

# ICU summary
createGeoMap(stateHosp_20220109, 
             yVars=list("pctCovidICU"=c("label"="Covid", "color"="red"), 
                        "pctICU"=c("label"="Total", "color"="black")
                        ), 
             fullList=list("pctICU"=expression(icu_beds_occupied/icu_beds), 
                           "pctCovidICU"=expression(adult_icu_covid/icu_beds)
                           ), 
             plotTitle="Average % ICU Capacity Filled by Week", 
             plotSubtitle="August 2020 to December 2021", 
             plotScaleLabel="% ICU\nUsed", 
             returnData=TRUE
             )

## # A tibble: 3,774 x 13
##    state collection_week total_beds adult_beds adult_beds_occu~ adult_beds_covid
##    <chr> <date>               <dbl>      <dbl>            <dbl>            <dbl>
##  1 AK    2020-07-31           1670.       356.             516.             32.1
##  2 AK    2020-08-07           1667.       356              534.             38  
##  3 AK    2020-08-14           1659        356.             526.             26.3
##  4 AK    2020-08-21           1662.       476.             496.             24.9
##  5 AK    2020-08-28           1651.       475.             496.             20.6
##  6 AK    2020-09-04           1608        506              510.             20  
##  7 AK    2020-09-11           1631.       506              550.             25.6
##  8 AK    2020-09-18           1589.       506              378.             32.7
##  9 AK    2020-09-25           1502        506              661.             29.8
## 10 AK    2020-10-02           1527.       937              651.             28.5
## # ... with 3,764 more rows, and 7 more variables: inpatient_beds <dbl>,
## #   icu_beds <dbl>, icu_beds_occupied <dbl>, adult_icu_covid <dbl>, n <int>,
## #   pctICU <dbl>, pctCovidICU <dbl>
# Adult beds summary
createGeoMap(stateHosp_20220109, 
             yVars=list("pctCovidAdult"=c("label"="Covid", "color"="red"), 
                        "pctAdult"=c("label"="Total", "color"="black")
                        ), 
             fullList=list("pctAdult"=expression(adult_beds_occupied/adult_beds), 
                           "pctCovidAdult"=expression(adult_beds_covid/adult_beds)
                           ), 
             plotTitle="Average % Adult Beds Capacity Filled by Week", 
             plotSubtitle="August 2020 to December 2021", 
             plotScaleLabel="% Adult\nBeds\nUsed", 
             facetScaleType="free_y",
             returnData=TRUE
             )

## # A tibble: 3,774 x 13
##    state collection_week total_beds adult_beds adult_beds_occu~ adult_beds_covid
##    <chr> <date>               <dbl>      <dbl>            <dbl>            <dbl>
##  1 AK    2020-07-31           1670.       356.             516.             32.1
##  2 AK    2020-08-07           1667.       356              534.             38  
##  3 AK    2020-08-14           1659        356.             526.             26.3
##  4 AK    2020-08-21           1662.       476.             496.             24.9
##  5 AK    2020-08-28           1651.       475.             496.             20.6
##  6 AK    2020-09-04           1608        506              510.             20  
##  7 AK    2020-09-11           1631.       506              550.             25.6
##  8 AK    2020-09-18           1589.       506              378.             32.7
##  9 AK    2020-09-25           1502        506              661.             29.8
## 10 AK    2020-10-02           1527.       937              651.             28.5
## # ... with 3,764 more rows, and 7 more variables: inpatient_beds <dbl>,
## #   icu_beds <dbl>, icu_beds_occupied <dbl>, adult_icu_covid <dbl>, n <int>,
## #   pctAdult <dbl>, pctCovidAdult <dbl>
# Cases per million summary
createGeoMap(cdc_daily_220103$dfPerCapita, 
             yVars=list("cpm7"=c("label"="Rolling\n7-day\ncases", "color"="red")), 
             xVar="date", 
             plotTitle="Cases per-million per day (rolling 7-day average)", 
             plotSubtitle="January 2020 to December 2021", 
             plotScaleLabel="", 
             hLine=NULL,
             returnData=TRUE
             )
## Warning: Removed 8 row(s) containing missing values (geom_path).

## # A tibble: 36,474 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-01-01 AL           NA         NA        NA         NA    NA         NA
##  2 2020-01-01 HI           NA         NA        NA         NA     0         NA
##  3 2020-01-01 IN           NA         NA        NA         NA     0         NA
##  4 2020-01-01 LA           NA         NA        NA         NA    NA         NA
##  5 2020-01-01 MN           NA         NA        NA         NA     0         NA
##  6 2020-01-01 MT           NA         NA        NA         NA     0         NA
##  7 2020-01-01 NC           NA         NA        NA         NA     0         NA
##  8 2020-01-01 TX           NA         NA        NA         NA     0         NA
##  9 2020-01-02 AL           NA         NA        NA         NA    NA         NA
## 10 2020-01-02 HI           NA         NA        NA         NA     0         NA
## # ... with 36,464 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>
# Deaths per million summary
createGeoMap(cdc_daily_220103$dfPerCapita, 
             yVars=list("dpm7"=c("label"="Rolling\n7-day\ndeaths", "color"="red")), 
             xVar="date", 
             plotTitle="Deaths per-million per day (rolling 7-day average)", 
             plotSubtitle="January 2020 to December 2021", 
             plotScaleLabel="", 
             hLine=NULL,
             returnData=TRUE
             )
## Warning: Removed 8 row(s) containing missing values (geom_path).

## # A tibble: 36,474 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-01-01 AL           NA         NA        NA         NA    NA         NA
##  2 2020-01-01 HI           NA         NA        NA         NA     0         NA
##  3 2020-01-01 IN           NA         NA        NA         NA     0         NA
##  4 2020-01-01 LA           NA         NA        NA         NA    NA         NA
##  5 2020-01-01 MN           NA         NA        NA         NA     0         NA
##  6 2020-01-01 MT           NA         NA        NA         NA     0         NA
##  7 2020-01-01 NC           NA         NA        NA         NA     0         NA
##  8 2020-01-01 TX           NA         NA        NA         NA     0         NA
##  9 2020-01-02 AL           NA         NA        NA         NA    NA         NA
## 10 2020-01-02 HI           NA         NA        NA         NA     0         NA
## # ... with 36,464 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>
# Hospitalized per million summary
createGeoMap(cdc_daily_220103$dfPerCapita, 
             yVars=list("hpm7"=c("label"="Rolling\n7-day\nhospitalized", "color"="red")), 
             xVar="date", 
             plotTitle="In-hospital per-million per day (rolling 7-day average)", 
             plotSubtitle="January 2020 to December 2021", 
             plotScaleLabel="", 
             hLine=c(500),
             returnData=TRUE
             )
## Warning: Removed 54 row(s) containing missing values (geom_path).

## # A tibble: 36,474 x 34
##    date       state tot_cases tot_deaths new_cases new_deaths   inp hosp_adult
##    <date>     <chr>     <dbl>      <dbl>     <dbl>      <dbl> <dbl>      <dbl>
##  1 2020-01-01 AL           NA         NA        NA         NA    NA         NA
##  2 2020-01-01 HI           NA         NA        NA         NA     0         NA
##  3 2020-01-01 IN           NA         NA        NA         NA     0         NA
##  4 2020-01-01 LA           NA         NA        NA         NA    NA         NA
##  5 2020-01-01 MN           NA         NA        NA         NA     0         NA
##  6 2020-01-01 MT           NA         NA        NA         NA     0         NA
##  7 2020-01-01 NC           NA         NA        NA         NA     0         NA
##  8 2020-01-01 TX           NA         NA        NA         NA     0         NA
##  9 2020-01-02 AL           NA         NA        NA         NA    NA         NA
## 10 2020-01-02 HI           NA         NA        NA         NA     0         NA
## # ... with 36,464 more rows, and 26 more variables: hosp_ped <dbl>, vxa <dbl>,
## #   vxc <dbl>, vxcpoppct <dbl>, vxcgte65 <dbl>, vxcgte65pct <dbl>,
## #   vxcgte18 <dbl>, vxcgte18pct <dbl>, tcpm <dbl>, tdpm <dbl>, cpm <dbl>,
## #   dpm <dbl>, hpm <dbl>, ahpm <dbl>, phpm <dbl>, vxapm <dbl>, vxcpm <dbl>,
## #   tcpm7 <dbl>, tdpm7 <dbl>, cpm7 <dbl>, dpm7 <dbl>, hpm7 <dbl>, ahpm7 <dbl>,
## #   phpm7 <dbl>, vxapm7 <dbl>, vxcpm7 <dbl>

Comparisons are made of change in cases or deaths vs. vaccines by state:

dec2022Data <- cdc_daily_220103$dfPerCapita %>%
    select(state, date, cpm, dpm, vxcpoppct, vxcgte18pct, vxcgte65pct) %>%
    filter(date <= "2021-12-30", date >= "2021-12-01") %>%
    arrange(state, date) %>%
    group_by(state) %>%
    summarize(across(ends_with("pm"), .fn=sum, na.rm=TRUE), 
              across(starts_with("vxc"), .fn=max), 
              .groups="drop"
              )
dec2022Data
## # A tibble: 51 x 6
##    state    cpm   dpm vxcpoppct vxcgte18pct vxcgte65pct
##    <chr>  <dbl> <dbl>     <dbl>       <dbl>       <dbl>
##  1 AK     8205.  21.9      56.3        67.7        84.2
##  2 AL    10464.  29.0      47.6        57.8        79.6
##  3 AR    11164. 154.       51.2        61.3        78.3
##  4 AZ    14286. 262.       57          67.4        83.6
##  5 CA     9074.  51.3      66.1        76.9        86.7
##  6 CO    15572. 182.       66.2        76.5        89.2
##  7 CT    24822.  71.5      74.6        84.8        94.6
##  8 DC    38787.  21.3      67.6        77.3        88.8
##  9 DE    24311. 111.       64.2        74.7        92.8
## 10 FL    22070.  18.6      63.4        73.7        88.9
## # ... with 41 more rows
# Pairs plot for vaccines data
pairs(dec2022Data %>% select(starts_with("vxc")), 
      main="Relationship among vaccine rates by state\nas of December 2021"
      )

# Relationship between deaths and cases
dec2022Data %>%
    ggplot(aes(x=cpm, y=dpm)) + 
    geom_point() + 
    geom_smooth(method="lm") + 
    labs(title="Relationship between vaccines and cases (each point is a state)", 
         subtitle="Data from December 2021", 
         x="New cases per million in December 2021", 
         y="New deaths per million in December 2021"
         ) + 
    lims(x=c(0, NA), y=c(0, NA))
## `geom_smooth()` using formula 'y ~ x'

# Relationship between vaccines and cases
dec2022Data %>%
    ggplot(aes(x=vxcpoppct, y=cpm)) + 
    geom_point() + 
    geom_smooth(method="lm") + 
    labs(title="Relationship between vaccines and cases (each point is a state)", 
         subtitle="Data from December 2021", 
         x="% Population fully vaccinated as of 30-DEC-2021", 
         y="New cases per million in December 2021"
         ) + 
    lims(y=c(0, NA), x=c(0, 100))
## `geom_smooth()` using formula 'y ~ x'

# Relationship between vaccines and deaths
dec2022Data %>%
    ggplot(aes(x=vxcpoppct, y=dpm)) + 
    geom_point() + 
    geom_smooth(method="lm") + 
    labs(title="Relationship between vaccines and deaths (each point is a state)", 
         subtitle="Data from December 2021", 
         x="% Population fully vaccinated as of 30-DEC-2021", 
         y="New deaths per million in December 2021"
         ) + 
    lims(y=c(0, NA), x=c(0, 100))
## `geom_smooth()` using formula 'y ~ x'

# Relationship between CFR and vaccines
dec2022Data %>%
    ggplot(aes(x=vxcpoppct, y=dpm/cpm)) + 
    geom_point() + 
    geom_smooth(method="lm") + 
    labs(title="Relationship between vaccines and CFR (each point is a state)", 
         subtitle="Data from December 2021", 
         x="% Population fully vaccinated as of 30-DEC-2021", 
         y="Crude case fatality rate (deaths/cases) in December 2021"
         ) + 
    lims(y=c(0, NA), x=c(0, 100))
## `geom_smooth()` using formula 'y ~ x'

Back envelope: